OS X Command Line Tips

Here are some OS X command line tips which I have collected. All have been tested with OS X 10.5 Leopard.

To Create a DMG from a folder:

hdiutil create name.dmg -srcfolder ~/Desktop/FolderName

To restart the OS X dock:
Restart Dock or killall Dock

You may notice if you use network shares that OS X leaves .DSShare files on the network shares. While these aren’t visable to OS X users, if you have other users accessing the same share they will see these files in every directory. Since these files simply save the appearance of the folder in OS X, disabling it shouldn’t have any adverse effect:
defaults write com.apple.desktopservices DSDontWriteNetworkStores true

In order to eject a stuck CD/DVD you can use the below command. Sometimes the CD remains in the tray but a desktop icon is no longer visable. This command line eject command will eject the CD.
drutil tray open

To reset a login password, start OS X with command+S which will start the system in single user mode. Then type:
fsck -fy mount -uw / launchctl load /System/Library/LaunchDaemons/com.apple.DirectoryServices.plist dscl . -passwd /Users/UserName newpassword

To convert a DMG file to an ISO File:
hdiutil convert /path/to/filename.dmg -format UDTO -o /path/to/savefile.iso

List open TCP/UDP ports:
netstat -lnp TCP
netstat -lnp UDP
lsof -i -P

List contents of DMG/PKG files:
lsbom .pkg/Contents/Archive.com> |more
|

Using SSMTP to Replace Sendmail (Gmail Config)

Properly configuring Sendmail can be a real pain. Especially when all you need is to simply get email off of a system and send to remote email addresses. For this, SSMTP may be the solution. For my setup I simply want to send email from my system through Gmail.

SSMTP can be downloaded from here:


http://ftp.debian.org/debian/pool/main/s/ssmtp/ssmtp_2.62.orig.tar.gz

or using yum in Fedora 9 to install SSMTP:

yum install ssmtp

The configuration file is /etc/ssmtp/ssmtp.conf

root=name@example.com
mailhub=smtp.gmail.com:587
rewriteDomain=
hostname=smtp.gmail.com:587
UseSTARTTLS=YES
AuthUser=gmailusername
AuthPass=gmailpassword
FromLineOverride=YES


Replace AuthUser and AuthPass with your Google Gmail username and password. The username should not have @gmail appended. Also change root=name@example.com to be the email address which should originate the email.

To make things easier I also setup a separate gmail account which just handles my outbound email from the system. If you use the same gmail account to send and then view the received email; it will never appear in the inbox.

The easiest solution is to create a separate gmail account to originate the email.

Personally, I am using SSMTP to send voicemail messages attached to an email from the Asterisk VoIP System. All I had to change in the Asterisk voicemail.conf file was the following:


;mailcmd=/usr/sbin/sendmail -t

mailcmd=ssmtp -t


My voicemail is then attached to an email as a wave file.


|