11 Unix Commands Every Mac Geek Should Know

Just imagine, a little over 20 years ago we were barely able to drag a mouse across the screen, let alone get around a desktop interface without typing in a few command lines.

Just imagine, a little over 20 years ago we were barely able to drag a mouse across the screen, let alone get around a desktop interface without typing in a few command lines. Forunately, things have drastically changed, but the command line still provides a powerful way of interacting with your Mac.

Unfortunately, most Mac users never dive into Unix because of how intimidating it can seem at first. But familiarizing yourself with it -- even a little bit -- is a great way to build up your coding arsenal. We rounded up some of the most utilized Unix commands you should know so you can get started tinkering with Terminal.

Because the Mac is based around a Unix kernel, the commands you learn below can be used with Mac, Unix, or Linux-based systems. Windows, however, uses different Microsoft DOS-based commands that are not compatible with Unix, and vice-versa.

Let’s get started learning some Unix commands.

Open Terminal (located in /Application/Utilities). You will notice that soon after it opens, you get a prompt similar to the one shown in the image above. This prompt will have the computer name, followed by a colon, a tilde, and the username of the logged in user, ended with a dollar sign ($). This prompt means that the Terminal is waiting for keyboard input.

1. ls

This command is used to list the directories and files while browsing through the command line. This command is typed with a lower-case “L” and “S” followed by the enter key (to send the command).

After typing the command, the Terminal screen will have all of the files and directories listed inside of the working directory.

There are two variations on this command that provides more functionality than just listing the files and folders for a particular directory. These commands are:

ls -l - Gives a long listing of the files and directories in the current directory. In addition, this command will also show the permissions, user the file/directory belongs to, and the creation date.

ls -a - Lists all of the files/directories (including hidden files) in the current directory. This command is useful if you have a hidden file that you need to find, edit, or delete.

2. cd

No, we’re not talking about those old compact discs that people used to listen to, we’re talking about “change directory.” This command does just that. Type this command followed by the name of a directory that you wish to change to, and it’ll change to that directory.

If you had a Music directory inside of the current folder you’re browsing, you could type:

cd Music

This would change to the music directory.

Just like the ls command, there’s a few variations on the cd command:

cd - Just typing the command without a directory name after it will take you back to your home directory.

cd .. - Typing the command with two periods after it will take you one-level up in the hierarchy (this means the parent directory to the directory that you’re currently in). So, if you were in the Music directory and wanted to move back up to the parent directory you just moved from, you could type this command. Think of this functionality as pressing the back button in a Finder window.

3. pwd

Pwd stands for “print working directory.” The working directory is whatever folder you’re currently in, which typically is the receiver of an action (such as directory creation or deleting files inside of a certain directory). So, if you’re ever uncertain about which directory you’re in, just typed pwd and Terminal will spit back to you the directory location.