Common Unix Commands

Common Command Line Interface commands for the unix family, including Linux and Mac OS X.

Command-Chaining Operators

Command Description
AND - OR && - || Combining and AND and OR operator acts like an if-else statement
AND && Execute proceeding command only if the preceding command succeeds with an exit status of 0
Ampersand & Run the preceding command in the background
Group {} Group two or more commands, dependent on the preceding operand.
NOT ! Execute all except the condition provided
OR || Execute proceeding command only if the preceding command fails with an exit status of 1
PIPE | Output from the preceding command is fed to the proceeding command
Precedence () Execute commands with precedence such as in math
Semi-colon ; Run the preceding command sequentially

File Management


Change working directory.

Command Description
$ cd ~/ Change to home directory.
$ cd .. Change working directory to one level back.


Clear the terminal output.

Command Description
$ clear Clear the terminal output.


Recursively finds files within path.

Command Description
$ find ~/ -name Finds the file within the users home directory.


Find filenames quickly by using a database.

Command Description
$ locate *.md -n 20 List filenames ending with .md, and limit queries to 20.


List files within working directory.

Command Description
$ ls -1 *.md List files that ends with .md, and force output to be one entry per line.


Displays manual for command. Pressing q quits the process.

Command Description
$ man cd Displays manual for the ls command.


Create directory if they do not already exist.

Command Description
$ mkdir wiki Create directory named wiki.


Move and or rename file/folder from source to destination.

Command Description
$ mv commands/ Move to the commands directory, and name the file


Return working directory name.

Command Description
$ pwn Return working directory name.


Removes directory entries. Be very careful with this command.

Command Description
$ rm Remove file named
$ rm -rf .DS_Store Removes all Mac Desktop Servies Store files, recursively.


Removes directories.

Command Description
$ rmdir docs Remove directory named docs.


Create a file with default permissions.

Command Description
$ touch Create file, if it does not exist. If it does, change modification and access times.

Power Management


Stop the system.

Command Description
$ sudo halt Stop the system.


Restart the system.

Command Description
$ sudo reboot Restart the system.

SCP (Secure Copy)

Copies files between hosts on a network. It uses ssh for data transfer. This comes in handy transferring files from your desktop to your arcade pc or raspberry pi. Be careful as scp will overwrite files without warning.

Command Description
$ scp [OPTION] [user@SRC_HOST:]file1 [user@DEST_HOST:]file2 Copies files between hosts on a network.
$ sudo scp -r wiki/ pi@raspberrypi.local:~/ Copy the wiki directory recursively to the user home directory on the raspberry pi.