username Asked: 2009-05-13 04:23:10 +0800 CST2009-05-13 04:23:10 +0800 CST 2009-05-13 04:23:10 +0800 CST What are useful Command-line Commands on Mac OS X? 772 Per the Windows and Linux threads, what commands do you find most useful in Mac OS X Server (or Client)? mac-osx-server mac command-line-interface osx-leopard 30 Answers Voted Tim 2009-05-15T03:40:24+08:002009-05-15T03:40:24+08:00 say "some text" Famously used for getting people back into their apartments, say takes your arguments and reads them aloud through the audio output device. kch 2009-05-20T15:32:29+08:002009-05-20T15:32:29+08:00 pbpaste and pbcopy to interact with the pasteboard (aka clipboard). Examples: # copies the directory listing ls -l | pbcopy # get pasteboard lines containing foo and save them in a_file pbpaste | grep foo > a_file I think they default to using the macroman encoding, so if you want UTF-8 (which you do) you should check out these links: http://sigpipe.macromates.com/2005/10/11/clipboard-access-from-shell-utf-8/ http://www.macosxhints.com/article.php?story=20081231012753422&query=pbpaste username 2009-05-13T04:30:10+08:002009-05-13T04:30:10+08:00 fs_usage Lets you monitor file system activity. Handy if you want to see what files some app creates. See http://rentzsch.com/macosx/fs_usageIntro for more explanation. richardhoskins 2009-05-13T08:49:05+08:002009-05-13T08:49:05+08:00 open . Opens a finder window in the current working directory. Gary Chambers 2009-05-30T12:51:12+08:002009-05-30T12:51:12+08:00 From the command line, I like having the ability to: Create and burn a "universal" CD/DVD: $ mkisofs -allow-multidot -allow-leading-dots -d -hide-rr-moved \ -l -joliet-long -R -T -v \ -V VOLUME_NAME -o output.iso root-cd-dir/ $ hdiutil burn -noverifyburn output.iso Create an ISO image from a CD/DVD: $ diskutil unmountDisk /dev/disk2s0 $ dd if=/dev/disk2s0 of=cdname.iso bs=32m Being able to forget the otool command when I'm seeking ldd: $ alias ldd='printf "Sending command to \'\''otool -L\'\'' --\n" && otool -L' Mount a disk image from the command line: $ hdid diskimage.dmg (or .iso) Use preview to access a man page: $ man -t rsync | open -f -a /Applications/Preview.app Jason Luther 2009-05-13T05:25:43+08:002009-05-13T05:25:43+08:00 The 'airport' CLI utility is my favorite. See http://osxdaily.com/2007/01/18/airport-the-little-known-command-line-wireless-utility/. It will show you details like the signal level, noise level, and the BSSID of the AP you're associated to. username 2009-05-13T04:37:15+08:002009-05-13T04:37:15+08:00 ipconfig getpacket en0 Displays network configuration for the primary Ethernet interface (en0). If you're used to Windows and think "ipconfig" is broken - it's not ;-) You just need to add a couple arguments James 2009-06-21T05:12:19+08:002009-06-21T05:12:19+08:00 drutil tray open Invaluable (over ssh) when there's no keyboard connected since the eject button on Apple optical drives isn't accessible from outside the case. w00t 2009-08-18T16:33:15+08:002009-08-18T16:33:15+08:00 It can't be said enough, "open" is great. You can open documents in their GUI program and you can select the GUI program with -a as well. For example, open -a vlc movie.avi will open VLC and tell it to load movie.avi in your current dir. open movie.avi would open it with whatever program is the default. If you just want to open a program, you can do that too: open -a system\ preferences will run System Preferences. You can open Urls too: open vnc://myserver:5900 will open Screen Sharing and connect to myserver. Check out man open to see all flags you can use. dvoita 2009-05-30T14:24:40+08:002009-05-30T14:24:40+08:00 softwareupdate Update your mac from the CLI.
Famously used for getting people back into their apartments,
say
takes your arguments and reads them aloud through the audio output device.pbpaste
andpbcopy
to interact with the pasteboard (aka clipboard).Examples:
I think they default to using the macroman encoding, so if you want UTF-8 (which you do) you should check out these links:
Lets you monitor file system activity. Handy if you want to see what files some app creates. See http://rentzsch.com/macosx/fs_usageIntro for more explanation.
Opens a finder window in the current working directory.
From the command line, I like having the ability to:
Create and burn a "universal" CD/DVD:
Create an ISO image from a CD/DVD:
Being able to forget the otool command when I'm seeking ldd:
Mount a disk image from the command line:
Use preview to access a man page:
The 'airport' CLI utility is my favorite. See http://osxdaily.com/2007/01/18/airport-the-little-known-command-line-wireless-utility/. It will show you details like the signal level, noise level, and the BSSID of the AP you're associated to.
Displays network configuration for the primary Ethernet interface (en0).
If you're used to Windows and think "ipconfig" is broken - it's not ;-) You just need to add a couple arguments
Invaluable (over ssh) when there's no keyboard connected since the eject button on Apple optical drives isn't accessible from outside the case.
It can't be said enough, "open" is great. You can open documents in their GUI program and you can select the GUI program with -a as well. For example,
will open VLC and tell it to load movie.avi in your current dir.
would open it with whatever program is the default. If you just want to open a program, you can do that too:
will run System Preferences. You can open Urls too:
will open Screen Sharing and connect to myserver.
Check out
to see all flags you can use.
Update your mac from the CLI.