Manage VMware virtual machines from the command line

To control VMware Workstation Virtual Machines from the command line use the vmrun utility. For instance, to stop a running virtual machine use this command:

# vmrun stop myvm.vmx

For a comprehensive guide on vmrun take a look at this document.

Indent first paragraph of the section in Latex

By default Latex indents all the paragraphs except the first paragraph of the section. To modify this behavior include the indentfirst package in your document’s preamble:

 \usepackage{indentfirst}

Send mail from the command line on Mac OSX

I’ll be using my Gmail account to send mail. The first step is to configure the local Postfix server as a relay. Edit /etc/postfix/main.cf:

sudo vim /etc/postfix/main.cf

Search for a “relayhost=” line and add the following after it:

relayhost = smtp.gmail.com:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options =
smtp_sasl_local_domain = yourdomain.com
#smtpd_sasl_application_name = smtpd
broken_sasl_auth_clients = yes
smtpd_pw_server_security_options = noanonymous
smtp_use_tls=yes
smtp_tls_security_level=encrypt
tls_random_source=dev:/dev/urandom

Next create /etc/postfix/sasl_passwd and add the following (replace username and password accordingly):

smtp.gmail.com:587 username@gmail.com:password

Next run the following commands:

$ sudo postmap hash:/etc/postfix/sasl_passwd
$ sudo chown root:wheel /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db
$ sudo chmod 600 /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db

You should be able to send mail from the command line now:

$ mail -s "Test" username@domain.com

You can check mail’s log file at /var/log/mail.log

To be able to send attachments from the command line (true attachments that graphical mail clients understand) install mutt:

$ curl -O ftp://ftp.mutt.org/mutt/devel/mutt-1.5.20.tar.gz
$ tar xfzvv mutt-1.5.20.tar.gz 
$ cd mutt-1.5.20/
$ ./configure
$ make
$ sudo make install

To send attachments use the following command:

echo "text body" | mutt -s "subject" -a file.dat -- username@domain.com

Or even better:

for i in {1..1000}; do echo "text body" | mutt -s "subject" -a file.dat -- username@domain.com; done

Happy mailing!

First registered domain name

Have you ever been curious about the first registered domain name? Well, it was symbolics.com.

Setting up OpenSSH public key authentication

First upload your public key to the server you want to log in:

scp .ssh/id_rsa.pub user@1.2.3.4:/home/user

On the server, add the public key file to the authorized_keys file:

cat id_rsa.pub >> .ssh/authorized_keys

Now you can login using public key authentication and you don’t have to enter a password anymore.

DNS query to find mail servers

To find which servers handle mail for a particular domain use dig:

# dig google.com MX
;; QUESTION SECTION:
;google.com.			IN	MX
 
;; ANSWER SECTION:
google.com.		561	IN	MX	100 google.com.s9a1.psmtp.com.
google.com.		561	IN	MX	100 google.com.s9a2.psmtp.com.
google.com.		561	IN	MX	10 smtp1.google.com.
google.com.		561	IN	MX	10 smtp2.google.com.
google.com.		561	IN	MX	10 smtp3.google.com.
google.com.		561	IN	MX	10 smtp4.google.com.

Show hidden files in Finder

To display hidden files in Finder type the following commands in the Terminal:

$ defaults write com.apple.finder AppleShowAllFiles TRUE
$ killall Finder

Add new packages to your MacTex installation

To add new packages to your Mactex installation follow these steps:

$ mkdir ~/Library/texmf/tex/latex/newpackage/
$ cp newpackage.sty ~/Library/texmf/tex/latex/newpackage/

That’s it. No need to re-index package list or something.

Snow Leopard (Mac OSX 10.6) is here

mac106buena Snow Leopard (Mac OSX 10.6) is here

Fix overfull problems when too many consecutive empty sections in Latex

I’m using Doxygen to document some C source code. This tool generates multiple sections in the Latex document (one for each variable). These sections are empty (i.e. they only have a title, no text). The problem is that Latex doesn’t automatically break the page when it should, and the section titles go beyond the margins (in fact many titles are not displayed at all).

To solve the issue add the following code to the document’s preamble:

1
2
3
\makeatletter
\renewcommand\@afterheading{}
\makeatother