10 Mac OS X Command Line Utilities You Might Not Know About

mac_os_mac-os-x-command-lines-by-genniceI’ve written many posts about Windows 7 and now it’s time to give something to Mac community too. Just for the record: I am a PC and a Mac user so I guess that makes me neutral in endless war of Mac vs PC. That’s why you’ll see posts that cover both Mac and PC here on Gnoted. And now here’s something very useful for Mac users.

The Mac OS X command line interface is home to thousands of programs that the average user doesn’t know exists. Leveraging years of hard work by the GNU foundation and others in the open source community, Apple designed a wonderful OS that doesn’t “need” any use of the command line. While using the command line in Mac OS X is not necessary for the every day operation of a Macintosh, if you use it smart and correctly, it can save you a lot of time in many situations.

So here are 10 OS X command line utilities that you might not know about!
(if you did then good for you)

1. ssh

This little gem is included in every version of Mac OS X. Originally developed as drop-in replace to the rsh/rlogin programs, ssh has become a staple of the Linux/Unix(and now Mac OS X) community. Openssh’s primary use is secure remote administration. If you wish you enable Mac OS X’s built in SSH server you can do so by opening your System Preferences , clicking on “Sharing” and checking the box next to “Remote Login”. Now if you are on the road and wish to access your machine you can use a client like PuTTY (from a Windows machine) or “sshfrom a Mac OS X terminal window and connect to the IP address of your Mac. After logging in with your Username and Password you will be presented with complete access to the Mac OS X command line. Openssh has many, many more uses some of which are quite advanced. My personal favorite is using ssh as a SOCKS server to browse the web securely in public internet locations.

Check out this page for more ways to use ssh on a Mac!

2. top

Top is another classic utility that has long been in use by the Linux/Unix community. To use top, open a Terminal.app and type “top”. In less time it takes to blink you eye you should be presented with a window full of text. What you see is a list of every process currently running on your Macintosh. When my Mac is running slow, top is the first resource I use to figure out whats going on.

For a complete overview of top utility click here.

3. lsbom

lsbom is great for that paranoid voice in your head that you often times hear before you go and install some cool new utility you’ve found on a random Mac blog. With lsbom you can examine the contents of a Mac OS X installer (.pkg) and get a very detailed view of what is about to be placed into your Mac’s precious filesystem. To use lsbom, open up the Terminal.app and navigate to the place in your filesystem where the .pkg file resides. If your installer came on a .dmg, it might help to copy the .pkg to your desktop, and then cd ~Desktop. Once you have found where your .pkg resides, type “lsbom .pkg/Contents/Archive.bom> | more” and voila! You will see a complete list of files your new program wishes to install.

4. say

Now this command is unique to Mac OS X, and offers more fun than anything else. Try it out by opening Terminal.app and typing “say hello”.

5. softwareupdate

The “softwareupdate” command is a quick and easy way to install software updates from Apple. To use it, open up Terminal.app and type “softwareupdate -i -a” to install all available updates for your Macintosh. If you wish to only install “recommended” updates type “softwareupdate -i -r”.

6. ifconfig

The quickest, easiest way to figure out what ip address your Mac is using, is definitely “ifconfig”. To use ifconfig, open up Terminal.app, and type “ifconfig”. You will see a lot of information, including your network card’s MAC Address. I like to type “ifconfig | grep inet” to return just the ip information for my computer. You can disable a network interface (in this example “en0?) by typing “ifconfig en0 down”. You could bring back up with “ifconfig en0 up”. This can be much quicker than using the System Preferences window.

7. lipo

lipo (aptly named) is a utility that manipulates universal binaries in Mac OS X. A lot of (almost all) programs these days ship, or download as “Universal”, meaning they have binary code that both the powerpc and the Intel chips can understand. But since you probably don’t care about one of the two, you want to use lipo to “thin” down your binaries. For example if you wanted to thin the “Stickies” application to only contain Intel (i386) code:
cd /Applications
lipo Stickies.app/Contents/MacOS/Stickies -thin i386 -output Stickies.app/Contents/MacOS/Stickies.i386
cd Stickies.app/Contents/MacOS/
rm Stickies
mv Stickies.i386 Stickies

8. screencapture

screencapture offers a more advanced way (over command-shift-3) to take screen captures. To use it, open up your Terminal.app and try typing screencapture -iW ~/Desktop/screen.jpg. It will bring up a camera icon that is waiting to be clicked on a window. Once clicked, a file on your desktop called “screen.jpg” will be created that will contain a snapshot of whatever window you clicked on. You can of course, also take a snapshot of your entire screen by typing screencapture -S ~/Desktop/screen.jpg. If you really feel like being particular you can snag just a portion of your screen by typing screencapture -ic.

9 & 10. fink and darwinports

If you’ve had your fill with the base set of OS X command line utilities, its time to open your Terminal.app’s eyes to the rest of the oppen source world. Using darwinports or fink you can download and install hundreds of free open source applications to your computer. I have found that darwinports tends to have some of the more obscure open source projects, but fink seems to be rock solid. You can install them at the same time if you REALLY know what you are doing, but generally I would have to advise that you pick one or the other. Novice users may want to try out fink, as it ships with a program called Fink Commander which gives you point and click access to its repository of software. Give it a try!

DarwinPorts Website
Fink – Website

I hope you will find these helpful. Enjoy and feel free to share more OS X command line utilites that you know about and I will add them to the list above.

[tags]mac os x, apple, macintosh, mac, mac vs pc, top 10, command line, linux, operating system[/tags]
[thanks to OS X Daily]

Popular Posts:


6 Responses
  • Harshadewa Reply

    Wow!! This is a really nice blog mate. Do you accept donations?

    • GenniCe Reply

      Thanks for your kind comment Harshadewa, I think I don’t really need donations at this moment but, who knows… Maybe sometimes :) Anyway thank you and enjoy reading Gnoted!

  • JaneRadriges Reply

    The best information i have found exactly here. Keep going Thank you

  • Pwnasaurusrex Reply

    Really great tools man. You should include osascript as a command line tool. I use it all the time to SSH into my mates mac and have it do funny things. But seriously, really awesome tools, the lipid command is exactly what I’ve been looking for.

  • Craig Reply

    Very nice selection of term commands. Good work and thank you!

  • moonpixel Reply

    very nice, wasnt aware of screencapture -ic

Leave a Reply