Ten OS X Command Line Utilities You Might Not Know About
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 harnessed correctly, it can save you a lot of time, and occasionally give you a laugh. I hope you enjoy these ten OS X command line utilities!
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 “ssh” from 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 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 (like osxdaily). 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
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 (if you’re from the PC world, think print screen for Mac). 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
. Now go get some screenshots and send them over to osxdaily, we love ’em!
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. Check it out!
DarwinPorts Home
Fink – Home
Still interested in learning? Check out some more command line tips!
Need a better Gui.
The people who are carrying on about the gui alternative for screencapture are missing the point somewhat. The strength of command line applications is that they can be easily automated, and chained together to create useful tools. For example if I wanted to take a screenshot every minute for a whole day, it would be trivial to do this on the command line, but I’d love to see you try it with the keyboard shortcuts.
Or even more fun: I can log in to my desktop machine from my phone using a ssh client and have access to all the command line tools, even on a slow 3G connection.
The more I use the command line, the more I feel limited by the GUI.
[…] From https://osxdaily.com/2006/11/22/ten-os-x-command-line-utilities-you-might-not-know-about/ […]
I’d like to recommend htop as a replacement for top. There are a few prebuilt versions, or of course, you can compile it yourself. I also use iterm instead of terminal.app.
Nice post…Thanks
This is a good article, but I have to say the GNU comment is pretty out there. Mac OS X is built on various BSDs, notably FreeBSD, which has its own set of command-line tools that have nothing to do with GNU.
Although OS X does use GNU tools (notably the compiler, ‘gcc’), none of the programs in this list are by the GNU foundation except the catch-all final two ‘programs’ which of course let you install your own GNU utilities if you like.
What about the GUI? That’s the evolution of NextStep, a proprietary interface that came out of Steve Jobs’ previous company.
You make my day & live better than before. Big hands
[…] Ten OS X Command Line Utilities you might not know about […]
For the Screen Capture, you can do the thingy with the camera by just pressing CMD+SHITF+4 and then SPACE.
For just a portion of the screen is just CMD+SHIFT+4…
Although OS X does use GNU tools (notably the compiler, ‘gcc’), none of the programs in this list are by the GNU foundation except the catch-all final two ‘programs’ which of course let you install your own GNU utilities if you like.
[…] 10 OSX Line Commands From OSX daily. […]
for all those plebs that kept banging on about cmd shift 4, it only allows you to save the image as a PNG and not the extension of you choice, cocky little bstrds
That lsbom one looks handy. There another 40 here: http://www.leftcolumn.net/2009/02/15/40-useful-mac-os-x-shell-scripts-and-terminal-commands/
[…] Ten OS X Command Line Utilities you might not know about – OS X Daily 10 OS X command line items I didn't know about (well, didn't know all of them). (tags: utilities unix tutorials tutorial tools tips terminal ssh sysadmin) […]
Window problems? Go to Terminal>Preferences>Settings
[…] Found a site that has some cool terminal commands. The sites called OS X Daily. My favorite command was “top” which will show you in your terminal window all your computers cpu usages and more. […]
[…] Ten OS X Command Line Utilities you might not know about – OS X Daily […]
Everytime I try and open terminal all I get is a small box with only the round red x button – cant grab corner to expand and see what’s in it. Any kelp would be appriciated – e-mail Ray@cruisinstyle.com
Regarding softwareupdate, I’ve been using this for awhile, and while it’s always been reliable for me in the past, the last two major Mac OS X updates that I tried to install via softwareupdate completely hosed my machine. I’m now waiting to get to my machine to do updates. Not worth it, in my experience. Just a warning.
[…] Ten OS X Command Line Utilities you might not know about – OS X Daily (tags: mac osx terminal tips Apple cli unix) […]
[…] Also mentioned: the fun lipo and the indispensable top and ssh. —Gina Trapani Ten OS X Command Line Utilities you might not know about [OS X Daily] […]
Consider explaining the “lipo” joke to non-native English speakers. International vowel pronunciation would make the word sound like “lee’po”, not “lai’po” as in liposuction.
I didn’t notice the most widely used and arguably the most useful classic *nix utility: man – the manpages!
As in:
man say
Did you know you can get say to dictate from a file? (use -f filename)
Write to an aiff file? (-o filename)
Use a voice other than the system default? (use -v)
Very cool – I so can’t wait to turn on ssh access to my wife’s PB so I can shell in from work and ‘tell’ her things :)
‘man lipo’ gives you the full manual page for the lipo command. The man utility can help you figure out the finer points of almost any command line utility.
As a developer, it has many many (MANY) times reminded me of the syntax for different C/C++ library calls, Perl functions, shell script commands, etc. And as my own sysadmin, it has helped me tweak the formats and parameters of countless system and application configuration files, makefiles, etc.
type ‘man man’ to get man to tell you about himself :)
man is your friend :)
Aaah. The smell of political agendas in the morning air.
WzDD: If you’re going to be pedantic about it then you have to consider that “leverage” in this context means “to influence” or, if you press me “to adopt best practices”. So leveraging the work of others just means doing things the same way, it may not mean using the other’s work directly. If that wasn’t enough then I’d have to turn your attention to the “and others” part of that same sentence which clearly means “others that are not GNU in the open source community”.
Further, since you seem to be one of the anal types and you’ll try to nitpick: Do note that “open source” is in lowercase, which implies it’s not referring to any specific license (and definitely not to GNU, as that’s mentioned specifically and separately, probably because someone like you made a similarly snarky comment once).
Also, the paragraph clearly says that thanks to open source tools and ideas Mac OSX now has an interface that doesn’t require to use the terminal at all. What in heaven could that have anything to do with your clarification that the tools mentioned aren’t GNU? Is that even relevant other than two show us how much you know about GNU and how little about reading comprehension?
Obviously, if you ignored the article’s opening paragraph, clear as it was to the rest of us (admittedly, we don’t feel we have to defend our chosen politic cause), it’d be unfair to point out that your comment about NextStep is also unrelated (as previously explained) to whether there are GNU tools mentioned in the article, included in OSX or part of the GUI.
To summarise in a single line: “open source != GNU, BSD = open source (among others)”. Is OSX built on the shoulders of giants (to use a cliché, the giants here being open source works like GNU and BSD, as well as others less publicized), even if OSX’s GUI is believed (by those that need to brush up their computer history lessons) to be based in NextStep’s? Yes. It is. OSX has a LOT in debt to open source tools and movements.
FWIW, this attitude is what’s made Apple steadily remove all traces of GNU from OS X.
This is a good article, but I have to say the GNU comment is pretty out there. Mac OS X is built on various BSDs, notably FreeBSD, which has its own set of command-line tools that have nothing to do with GNU.
Although OS X does use GNU tools (notably the compiler, ‘gcc’), none of the programs in this list are by the GNU foundation except the catch-all final two ‘programs’ which of course let you install your own GNU utilities if you like.
What about the GUI? That’s the evolution of NextStep, a proprietary interface that came out of Steve Jobs’ previous company.
[…] “Ten OS X Command Line Utilities you might not know about: The Mac OS X command line interface is home to thousands of programs that the average user doesn’t know exists. While using the command line in Mac OS X is not necessary for the every day operation of a Macintosh, if harnessed correctly, it can save you a lot of time…”read more | digg story […]
For screencapture if you really want .jpg format use -tjpg, or for GIF -tgif and the one that’s really cool: -tpdf
Any format Quartz supports should work, a reference for all of them is here in table 3: http://developer.apple.com/graphicsimaging/workingwithimageio.html
[…] Also mentioned: the fun lipo and the indispensable top and ssh. —Gina Trapani Ten OS X Command Line Utilities you might not know about [OS X Daily] […]
[…] Also mentioned: the fun lipo and the indispensable top and ssh. —Gina Trapani Ten OS X Command Line Utilities you might not know about [OS X Daily] […]
[…] Also mentioned: the fun lipo and the indispensable top and ssh. —Gina Trapani Ten OS X Command Line Utilities you might not know about [OS X Daily] […]
Tip :
http://rixstep.com/4/0/clix/
Free & brilliant !
Rob, you need to have developer tools installed, it is on the first install disk for your mac.
apple doesnt think people want it, but they do its the firs thitng yous oudl do hwen yous inatll a new mac
when you get a new mac youw ant delveopre tolls if you dont ahve tools then you are msising a lot of your amcs ptoentails
Not listed here, but I’m scouring Google to no avail trying to find out why every tutorial to build software from source says to use “make,” yet for some reason, when I try to do this, it says “make: command not found.” Email me?
[…] …aus Sicht von OS X Daily. bookmark:Diesen Artikel in deine del.icio.us bookmarks aufnehmen… […]
[…] For more info, tips, and tricks, be sure to check out our other command line entries and read Ten OS X Command Line Utilities you might not know about. // […]
I can’t find ‘say’ utility. Can anyone help?
Thanks
[…] OS X Daily » Ten OS X Command Line Utilities you might not know about – Mac Apps, Tips, Tricks, and everything else related to Mac OS X Posted in bookmarks | Trackback | del.icio.us […]
Actually, in response to an earlier post…No underneath Mac OS X is not UNIX at all, it is a flavour or a UNIX type of OS called FreeBSD. Check it out, your MAC will tell you this. God forbid if they actually used UNIX we would have fewer ports for it and the price of your MAC would be even higher, as if it doesn’t cost enough to get a MAC already. I love MACs especially now they lay over the top of FreeBSD, but jesus! Trynig to buy a decent MAC you practically need to get a house loan to pay for it!
Great great
Thanks for your kindness!
I have already finished the translation and published here :)
[…] 原文标题:Ten OS X Command Line Utilities you might not know about […]
Hi, I’m a Mac user from China.
I leant something in this post. I hope more Chinese Mac users are able to read it. So I want to translate it to Chinese and publish on my blog. Can I?
I will appreciate your consideration about it.Thanks in advance.
Another one, right up there with “top”, is ps. It’s frequently invoked with “-aux”. My favorite way is with “-auxwww” which returns all the detail, not just the first 80 characters. It help a lot with greping for things buried at the end of long file paths and what not.
[…] commentaire jusqu’à présent Laissez un commentaire Fil RSS des commentaires pour cet article. URI de Trackback Laissez un commentaire Retour à la ligne et paragraphes automatiques, adresse courriel toujourscachée, code HTML permis: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> […]
[…] El articulo es este. Es divertido, pero cuidado, porque podrian hacer algo que luego lamenten… estan advertidos. […]
lsbom: You can also do this in Installer. Choose “Show Files” from the File menu. Also, “cd ~Desktop” will cd to the home folder of the user named “Desktop”. You meant “cd ~/Desktop”.
And what part of the OS X GUI is GNU?
Along with any of the screen capture hotkeys that people have mentioned, if you hold down ctrl while you do them the result will be saved to your clipboard rather than a file. Great for quickly getting them into photoshop.
[…] From OS X Daily: 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 […]
[…] You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site. Leave aReply […]
A detail, the author should have been aware of: You may use the command ‘screencapture -iW ~/Desktop/screen.jpg’, but the file suffix will NOT tell the tool what picture file format to use. I normally use PNG for screen shots (default on Tiger) and the ‘screen.jpg’ truely becomes a PNG. Just try: screencapture -iW ~/Desktop/screen.txt
Lots of people mentioned cmd-shift-4 + spacebar, but there’s another handy feature while doing screen shots. Pressing ctrl while clicking your window or releasing the mouse while defining your rectangle, the pictures destination isn’t a file on the desktop, it’s the system clipboard. Using GraphicConverter type cmd-J, here it is. If you plan to continue working with the screenshot, this is the best way – avoiding a temporary file on the desktop.
Bryan, type ‘arch’ in the terminal and you know the architecture spec you have to use.
Muy interesante y útilísimo para los que nos gusta los atajo.
¿Nos puede enviar una lista de más mandos para el terminal?
Siempre he tenidomiedo hacer algo con el termial pero ahora no gracias a ustedes.
¡Buen trabajo!
David
One question with the Lipo command. How would you tell it to strip away the Intel binary leaving only the PPC??
[…] OS X Daily » Ten OS X Command Line Utilities you might not know about – Mac Apps, Tips, Tricks, and everything else related to Mac OS X (tags: apple mac osx) […]
[…] Many of you know that underneath all the nicesness of Mac OS X is lots and lots of code, which is called UNIX, and you can access this by using the Terminal. However for the people who don’t know how to use it there are hoards of information to sift through, but OSX Daily has compiled the top 10 Command Line Utilities. A very interesting read. […]
Hey! That’s nifty!
Granted, I knew about “ssh” a long time ago, but never knew about “say.” That makes it easy to get someone’s attention if they’re near the server room. (How many times have you had to get someone to turn off the “Caps lock” when VNC’d into a machine? I’d resorted to opening TextEdit and using TextEdit>Services>Speach. This is a lot easier.)
But it tends to scare people. Guess there’s a downside to everything.
[…] OS X Daily » Ten OS X Command Line Utilities you might not know about 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. similar nonsense in: Uncategorized | No Comments » […]
[…] Ten OS X Command Line Utilities you might not know about OS X Daily » While using the command line in Mac OS X is not necessary for the every day operation of a Macintosh, if harnessed correctly, it can save you a lot of time, (tags: mac osx commandline) […]
I recently found a very interesting website:
http://alreadylinked.com/
There you can purchase ad space for your Blog etc.
yes, connect to an ssh server using -D8080, then in your browser prefs, tell it to you use a proxy server (socks proxy) tell it localhost, port 8080.
In tip 1, you talk about your favourite use of ssh – to browse the web securely. That sounds exactly what I need, can you elucidate?
[…] At last, I found a list with some interesting commands for the Mac OS terminal. Some of them are pretty much common knowledge (ssh? top?), but you might wanna annoy your co-workers with the “say” command ;-) Another one that is not in the list and really rocks in Mac OS is “open”. It works as if you double clicked on some file in Finder, really cool. […]
OK, seriously – how many people are going to add that “Screen Capture Tip” without realizing it’s already been said, a bazillion times!
Anyhow, nice list. Thanks.
lipo, lol i love it
Regarding #8, there are better ways to do this.
Entire Screen: Cmd-Shift-3
Selection: Cmd-Shift-4
Window: Cmd-Shift-4, spacebar
[…] There is no real way to “uninstall” an app in Unix, unless your app comes with a script to do so … so be forwarned. The article was posted here. […]
Depending on what you do with your machine,
I find
lsof -i handy to see what you are connected to as well as who is connected to you via tcp or udp
df -h will give you your drive space used and left as well as the drive space used and left on a mounded drive or share
then if you are looking for a file be sure to look at the find command
also if you want to compare 2 test files you should look at diff
These are commands I use often that a user who is new to the CLI might not know about and it might make their lives easier
As for screencapture.. I hope you are aware that cmd-shift-4 followed by space gives the exact same functionality as creencapture -iW ~/Desktop/screen.jpg
[…] • Go here for interesting terminal trivia […]
Excellent, I like that lsbom, someone needs to make a drap and drop app like this
[…] OS X Daily has a nice list of OS X command-line utilities today that you may have forgotten about or might never have encountered. For example, the article suggests using ifconfig to check your IP address or lsbom to peek at the contents of an OS X installer package. If the notion of extending your command line vocabulary appeals, it’s worth a visit to this quick article. You might pick up a trick or two you can incorporate into your day-to-day routines. […]
Regarding the screencapture command, you can take a screenshot of a single window by pressing command+shift+4 and then spacebar.
Note, the same can be done for the screen capture by pressing Command-shift-4, then, rather than dragging out a custom window, pressing space. It will once again bring up the camera icon, and is much quicker to type.
There’s also textutil, which provides Cocoa apps with the ability to convert MS Word files to RTF, text, Web archives and WordXML as well as vice-versa.
I don’t think it’s a good idea to muck around with stripping your application binaries of various bits of code. Aside of the possibility of mistyping something, some applications might inspect themselves to do sanity checks and version comparisons. You’re probably saving a few megabytes at most anyway. Less than one song.
Let the application be itself. :)
~/Desktop would be better as the path in #3.
Nice list, thanks! Didn’t know that say also works in the terminal.
Regarding tip #8…instead of a command in term (which is cool to know about) try command-shift-4,he space bar will toggle the camera and a target.
The camera is used for snapping up shots of windows you roll the mouse over and the target is used snap shots of a selection.
I prefer this method myself.
About the screenshots:
apple-shift-4
you now see a crosshair
press the space bar
voila, you can select one window to cap
:)
Regarding to taking screenshots – you do know that you can take pictures of parts of the screen (same as screencapture -i), or windows (screencapture -iW), using shift-cmd-4, and toggle between manual selection and capturing whole windows with the space bar?
No need for command line utilities for simple tasks like that.
The ditto command is also very useful. I think of it as cp on steroids. Or, rather, it’s cp, cpio, gzip, zip, and part of lipo all rolled into one! The good thing about ditto is that it preserves resource forks — or optionally ditch them — or even sequester them into a separate directory.
ditto is my friend.
this is a pretty cool collection of commandline tools. thanks!
DarwinPorts has switched its name to MacPorts:
http://www.macports.org/
I got a good laugh out of “say” :)
nice tip. you may want to post a warning about “lipo”; always backup the file before surgery. if only that were possible in real life.
Command-Shift-4 will bring up a marquee tool to take a screenshot of a selected area. Pressing the space bar will change it to the camera window capture tool described in tip 8. Of course, you can’t specify the name this way..