Mac OS X Command Line: A Command Reference

The Mac OS X Command line is a very powerful tool, allowing the experienced user to have more control over their Mac, by using the power of UNIX commands via the Terminal.

Mac OS X Terminal The Mac OS X Terminal Window

This section of the website will assume that you understand the basics, and are looking for more information about the various commands. If not then visit our Mac Unix page for an introduction to UNIX, as well as the basics of using the command line.

As you can probably guess there are hundreds of different command combinations, and most are standard UNIX commands.

We won't attempt to list all commands alphabetically, instead we will group them by function. So, if you happen to be looking for a command related to User Administration, for example, then click on the category name below to jump to the commands for that category.

Mac OS X Command Categories

The Mac commands are collected together under the following categories.

  • General Commands
  • User and Group Administration
  • Network

Common Commands

This category covers all of the commands that can be used daily via the Mac OS X Command Line, while performing other tasks via the command line.

These commands are used for general file manipulation, and general sys admin tasks.

The List Command - ls

The list command is used to view the contents of a directory, the output is a list showing the files and directories in the current working directory, or a different directory specified by a path in the command.

By adding options or switches to the command the information outputted for each file, and the way in which it is presented can be altered.

Command syntax: ls [Options] [Directory Path]

A three samples of the command are shown below;

localhost:~ jordan$ ls

localhost:~ jordan$ ls -l

localhost:~ jordan$ ls -la /Users

The options that can be used with this command are in the table below;

Option/Switch Description
-a List all files, including normally hidden.
-l Output list in long format.

The Copy Command - cp

The cp command can be used to copy a file to another file, or files in a directory to another directory, or files and directories in a hierarchy to another directory.

By adding options or switches after the command the copy command can be made to perform a specific task during the copying process.

Command syntax:
cp [Options] [Source File] [Destination File]
cp [Options] [File 1] ... [File n] [Destination Directory]

Two samples of the Mac OS X command line are shown below;

localhost:~ jordan$ cp name.txt name-copy.txt

localhost:~ jordan$ cp name1.txt name2.txt /newfiles

The options that can be used with this command are in the table below;

Option/Switch Description
-R If source is a directory, it copies all files.