Things that you might not know the Mac Terminal can do

Oct 18, 2008 07:01 GMT  ·  By
The Terminal icon one can find when browsing the Utilities folder in Grid mode from the dock.
2 photos
   The Terminal icon one can find when browsing the Utilities folder in Grid mode from the dock.

When it comes to command-line trickery and such I must confess I am all ears. Since the first time I got to use a command line interface while playing around with a Red Hat Linux powered box in high-school, the CLI has always amazed me. If you have ever used the Terminal in OS X, for example, I’m quite sure you understand the reason of my owe.

Yes, you can do pretty much everything using GUI-based apps these days but the fact that you can also do it just by entering a short command and hitting enter will give you a feeling of accomplishment that you can’t compare with anything else (just think about the first time you got the right output from a command that you wrote down and launched on your own and you’ll understand).

I have previously written about the wy one can use the Terminal and even customize its looks to match your tastes. Today is the time to write about a handful of command line uses that not many know about (certainly not the ones that are just starting using it).

Those of you who enjoy working with the Mighty Mouse might want to just kick for returning to the boring white black interface but I will take the risk and do it for the sake of those that love using the Terminal (or its pumped up brother iTerm) and are looking to put it at work in new ways each and every day.

The first thing your Mac Terminal is able to do and you might have not been aware of is sending the output you get from the command line programs to GUI enabled apps. Let’s say you want to see a list of processes running on your Mac and you go for the “ps ax” syntax. Everything OK right there but what can you do if you want to take output and send it to a friend, for example?

Nothing easier. You make use of a pipe and send the output to your default text editor into a new text file that you can edit and save. The command to be used is this: “ps ax | open –f” and the result will be quite impressive if you have never done this before. Of course it can be used to save output from any other CLI program not just ps, your imagination being the only limit (one cool use would be to pair the "| open -f" with a "system_profiler" command to get a comprehensive text summary for your Mac's hardware and software configuration).

Just a couple of things before going to the next command. You can send the output directly to the clipboard so it can be pasted in any other application you want not only in your text editor by using “ps ax | pbcopy”. Also there is another way to accomplish this, a more classic UNIX like, by writing it like this: “ps ax > textfile.txt”. It will also allow you to append the command line output to the file if you have previously created it by entering “ps ax >> textfile.txt”.

The second thing your Mac’s Terminal can do is find which applications use certain files. These can prove extremely useful and you will agree with me if you have stumbled upon an error message that told you a mounted disk could not be unmounted because a contained file was still in use. The hard way to solve this problem would be to try and guess which of the applications you are running at that moment is still using the file, but, as many Mac users have already found out, it can get where no one has gone before because, usually, the last you will be killing will be the one that had that exact file open.

The easy way is to open a Terminal window and run this: “sudo lsof | grep [volume name]” where the volume name is the name of the disk that refuses to unmount. The result of this command? It will display a list of processes that are using files from the disk that you can’t unmount and this way you will be able to simply kill it by using its attached PID (that will be the first number on the line containing the process that messed with you and your disk).

Just in case you are wondering why you should be using sudo: it is there to be sure the lsof command will display the processes opened by all users.

The next three things your Terminal can do for you will have to do with your Mac’s defaults.

The third thing that will allow your Mac to benefit the most from its multimedia side is enabling high definition trailers in the Front Row app. If you didn’t know about this one, here it is:

defaults write com.apple.frontrow EnableHDMovieTrailers Yes

Although I doubt that any of you could be interested in turning this feature off once it’s available, I must tell your that by replacing the Yes with a No and running the command again from the Terminal will stop Front Row from presenting you brand new movie trailers in HD quality.

The fourth thing you can do just by using your Terminal is to enable the URL tooltips that appear in Safari when hovering your mouse pointer above a link:

defaults write com.apple.Safari WebKitShowsURLsInToolTips Yes

Yes, I also thought it was enabled by default but it seems that Apple does not want its users to know what the whole anchor text for a URL link is. Also, like in the case of the command presented above, all you will have to do is place a No instead of the final Yes and rerun the modified command from the Terminal.

The fifth thing (and the last one which we’ll make all eye candy haters and CLI lovers out there rejoice) is the dialogue boxes speed up trick. You know what I’m talking about, those pretty looking and time consuming animation effects you see every time a dialogue box opens on your Mac. This command will make the boxes pop up on the screen instantly. The command you will have to run from the Terminal in order to achieve this is:

defaults write NSGlobalDomain NSWindowResizeTime 0.01

If you think things are just a little too fast for you after running it, you can always revert to the default value by replacing that 0.01 with a 0.2. As easy as that.

That pretty much sums up what I had in mind to write down for you on the matter and if you know other cool ways that I haven’t mentioned here or think that the other readers might want to know about, leave us a message in the comments.

Photo Gallery (2 Images)

The Terminal icon one can find when browsing the Utilities folder in Grid mode from the dock.
Running the "ps ax | open -f" command in the Terminal and viewing the output in TextEdit
Open gallery