11 Unix Commands Every Mac Geek Should Know
Posted 01/31/2011 at 2:26pm
| by Cory Bohon
6. mv / cp

These two commands are used to move and copy files.The first, mv is used to move files from one location to another. Let’s say that I had a file located in my user folder, but I wanted it moved to a folder called Documents. I would use the mv like this:
mv ~/test.txt ~/Documents/test.txt
This will move the file from the first location that you specified to the second location.
Let’s say that instead of moving the file from the first location to the second location, you wanted to copy it. That’s easy enough. Just replace the mv command with the cp command, like this:
cp ~/test.txt ~/Documents/test.txt
7. who

Have you ever wanted to find out who is logged onto your Mac? Perhaps you have a multi-user system, or have SSH enabled; either way, you might need to know who is logged in. This simple Terminal command can tell you very easily. Simply head to the command line and type in who. In a blink of an eye, the system will return a list of all the users currently logged on and what date and time they logged in. Pretty nifty, huh?
8. cat

Cat is a simple way to view the contents of a file. The name is short for “concatenate and display files.” Let’s say you have a file called “test.txt” in your working directory. You think you can delete it, but you’re not sure what the contents of the file are. Without having to open a command line editor like nano, emacs, vi, or vim, you can simply type in the following command followed by the file name:
cat test.txt
This command will then output the file’s contents to the screen.
9. sudo
Sometimes it may be necessary for you to run a command as an administrator. If you were to get an error like “Error: Insufficient privileges,” just type the sudo command before the command you were actually trying to type. This will in turn cause Terminal to ask you for your password to authenticate you as an administrator.
The sudo command is needed for things like chmod, MacPorts, and other administrative tasks.
10. control + C
Control + C is a way to tell a running command line-based program to quit and return you back to the command line prompt. So, if you were running a ping or other command line tool, just press Control + C to get back control.
11. clear
We saved the best and easiest for last. By now, you’ve no doubt tried many of the commands, but this can leave your Terminal command rather busy with text flowing here and there. If you want to get rid of all the previous commands and outputs being displayed on the screen, simply enter clear followed by the enter key. This will wipe your Terminal screen clean, ready for you to type more commands.
Follow this article's author, Cory Bohon on Twitter.