This is a list of basic Unix command and basic modifiers. Keep in mind that there are hundreds of commands and each command generally has many modifiers, so this is just the tip of the iceberg.

  • %> - Represents the Unix command prompt
  • (file path) - Represents the name of a file (e.g. blah.txt or /tmp/Hello.cpp) or a directory (e.g. /home or ../tmp)
  • (cmd name) - Represents the name of a command (i.e. mv or rm)
  • (src) - The source directory or filename
  • (dest) - The destination directory or filename
  • (proc id) - The ID of a running process (found using the "ps" command)
  • (uname) - A login username (i.e. the local-part of your USC E-mail address)
CommandOptionsSyntaxDescription
ls (none)

-a

-l
%> ls

%> ls -a

%> ls -l
List all the non-hidden files in the current working directory to the console

Display all files (hidden and non-hidden) in the current working directory

Display the details of all listed files (i.e. ownership, creation time, etc.)
echo (none)

-n
%> echo (string)

%> echo -n (string)
Print (string) followed by '\n', the <LF> character.

Print (string) (without <LF>)
cat (none) %> cat (file path) Dumps the entire contents of a file to the console
more (none) %> more (file path) Will display the contents of the file in the console window. Press 'Enter' to scroll line by line. Press spacebar to scroll by page. Press 'q' to quit.
pwd (none) %> pwd Displays the current working directory
cd (none) cd (file path) Change current working directory to (file path)
mkdir (none) %> mkdir (file path) Create a subdirectory named (file path) in the current working directory
cp (none)

-r
%> cp (src file path) (dest file path)

%> cp -r (src file path) (dest file path)
Copy a file from "src" to "dest"

Copy a file or directory recursively from "src" to "dest"
mv (none) %> mv (src file path) (dest file path) Move a file or directory from "src" to "dest"
man (none) %> man (cmd name) Displays the manual page for a given command (e.g. "%> man cp" will display the manual for the "cp" command). Press "q" to quit.
rm (none)

-r
%> rm (file path)

%> rm -r (file path)
Remove the given file.

Remove the given file or directory

BE CAREFUL WITH THIS COMMAND
touch (none) %> touch (file path) If the file does not exist, this will create a new, empty file. If the file does exist, it will update the "last modified time" (do this if you want to force something to recompile).
ps -x %> ps -gx Show all the processes currently running with your username and their associated process IDs (a.k.a. PIDs).
kill (none)

-9

-9 -1
%> kill (proc id)

%> kill -9 (proc id)

%> kill -9 -1
Kill the specified process.

Forcefully terminate the specified process (do this if normal "kill" doesn't work).

Forcefully kill all your processes and log you out (be careful with this).
pico (none) %> pico (file path) Open the specified file using the pico editor. If the specified file does not exist, pico can create it.
vi (none) %> vi (file path) Open the specified file using the vi editor. If the specified file does not exist, vi can create it.
emacs (none) %> emacs (file path) Open the specified file using the emacs editor. If the specified file does not exist, Emacs can create it.
exit (none) %> exit Terminate your current shell or current login.
Please note that the first part in a commandline must be either a built-in command of your command shell (bash or tcsh) or a program name. Therefore, if you are asked to enter a particular commandline and you don't know the meaning of that line of command, you should look at the manual (referred as "man pages") for that first part of that commandline. For example, if you don't know what "g++ -g -Wall -std=c++11 -DLOCALHOST=\"localhost\" -o hello Hello.cpp" would do, you should do "man g++" and look for things like "-g", "-W", etc., in the man pages of g++.