USC CSD Home
 

Unix Command Line Reference - CSCI 402, Summer 2014, MW Section

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.
 
Notations
  • %> - Represents the Unix command prompt
  • (file path) - Represents the name of a file (e.g. blah.txt or /temp/Hello.cpp) or a directory (e.g. /auto/home or ../temp)
  • (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. csci402)
  • (host) - A host (i.e. aludra.usc.edu)
 
Unix Commands
 
CommandArgumentsSyntaxDescription
ls (none)

-a

-l

%> ls

%> ls -a

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

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

Display the details of all listed files (i.e. ownership, creation time, etc.)
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.
cd (none) cd (file path) Change directory from the current directory to (file path)
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 from "src" to "dest"
mv (none) %> mv (src file path) (dest file path) Move a file or directory from "src" to "dest"
pwd (none) %> pwd Displays the current working directory
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 -gx %> 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).
emacs (none) %> emacs (file path) Open the specified file using the Emacs editor. If the specified file does not exist, Emacs 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.
ssh (none)

-Y
%> ssh (uname)@(host)

%> ssh -Y (uname)@(host)
Create a secure shell connection to the given host using the specified username. Use this to login remotely to machines like "aludra.usc.edu" or "nunki.usc.edu".

Create a secure shell connection with X11 forwarding to the given host using the specified username. If you want to be able to pop up windows such as Emacs or your program's GUI, you MUST use this option.
exit (none) %> exit Terminate your current shell or current login.
 

[Last updated Sat Sep 19 2020]    [Please see copyright regarding copying.]