Basic Commands

Basic commands for the Unix family, including Linux and Mac OS X.

Command-Chaining Operators

Syntax 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.

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


Clear the terminal output.

Syntax Description
$ clear Clear the terminal output.


Recursively finds files within path.

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


Find filenames quickly by using a database.

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


List files within working directory.

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


Displays manual for the utility. Pressing q quits the process.

Syntax Description
$ man cd Displays manual for the ls utility.


Create directory if they do not already exist.

Syntax Description
$ mkdir wiki Create directory named wiki.


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

Syntax Description
$ mv unix/ Move to the unix directory, and name the file


Return working directory name.

Syntax Description
$ pwn Return working directory name.


Removes directory entries. Be very careful with this command.

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


Removes directories.

Syntax Description
$ rmdir docs Remove directory named docs.


Create a file with default permissions.

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


Locates source/binary and manuals sections for specified files in a list of standard Linux places.

Syntax Description
$ whereis mame Where is the installed mame binary.

Removing .DS_Store Files

Find and remove all matches, recursively. This is incredibly useful for removing Desktop Services Store files (Mac OSX). Be sure to change into your target directory first!

$ cd wiki
$ find . -name '.DS_Store' -type f -delete

Power Management


Stop the system.

Syntax Description
$ sudo halt Stop the system.


Restart the system.

Syntax Description
$ sudo reboot Restart the system.