Unix and Linux Command Quick Reference Page

File Management


Lists the contents of your working directory.

ls -a

Lists all of your files, including the "dot" files. There are a number of files that start with a . that won't normally show up with when you type ls. An example of such a file is your .newsrc file.

ls -s

Gives you a listing of your files along with their size in kilobytes.

ls -l

Gives you a "long listing," which means that your files will be shown in one vertical column and the file size and file access modes for all files will be shown.

All of these switches can be combined, so one might type ls -as to list all of one's files and find their size.


Copies a file to a specified location. Can be used to copy a directory with files in it using cp –r .

Usage: cp [ -r ] [source file(s) or directory(ies)] [destination file(s) or directory(ies)]

Examples: cp ~/myfile ~/mydir/ cp file1.txt newfile.txt cp –r ~/myproject/ ~/myprojectbackup/


Moves (or renames) a file to a specified location. Similar to cp except that it deletes the source file (or directory, no option needed).

Usage: mv [source file(s) or directory(ies)] [destination file or directory(ies)]

Examples: mv ~/myoldfilename ~/mynewfilename mv file* ~/mydirectoryoffiles/ mv ~/mydir/ ~/myotherdir/


Deletes file(s) or directory trees. There is no undoing! Can be used to delete all files and subdirectories with rm –rf .

Usage: rm [-rf] [file or directory]

Examples: rm mytxtfile.txt rm –rf ~/mydir/ (removes the directory and everything in it) rm –rf ~/ (don't do this!)


Prints the working directory. This could be called your current path or view.


Changes your working directory or view or where you're “in” to another specified location.

Usage: cd [destination path]

Examples: cd ~/ (home directory) cd somedir/someotherdir/ cd / (root directory) cd .. (parent directory)


Creates a new directory. You can specify a location if you like.

Usage: mkdir [directory path and name]

Examples: mkdir newdir mkdir ~/newdir mkdir olddir/newdir


Removes (deletes) a directory. You can only use this on empty directories.

Usage: rmdir [directory path and name]

Examples: rmdir ~/olddir rmdir olddir/empty/

df -h ?? Lists all files and folders with their associated total sizes in KiloBytes?.

Usage: df – [directory path or file]

Examples: du –?? (from current directory) du –?? ~/.mozilla (displays sum of all files' sizes in your mozilla tree)


See description under Remote Access. Copies files or directories from one user account to another.


Modifies the permissions of files or directories. Permissions are rules about how and which users can access the files or directories. The three switches covered here are: r -read access, w -write access, x –execute access.

Usage: chmod [ + or - ]rwx [file(s) or directory]

Examples: chmod +r myfile (adds read access to a myfile) chmod –w myfile (removes write access to myfile) chmod +x myfile (adds execute access to myfile)

ln –s

Creates a symbolic link to a file or directory. Symbolic links are analagous to windows shortcuts, and are simply pointers. You can create one in your home directory to avoid having to cd into another directory you use frequently.

Usage: ln –s [link file] [target]

Examples: ln -s fortunelink /usr/local/share/terminfo/f/fortune ln –s otherlink ~/something/somethingelse

/bin/rm -rf

It's just like above, except you won't get the very data saving confirmation messages if you're deleting many files.

An alternative is to unalias rm which will use /bin/rm until you logout.

Program Management


The man unix tool is shorthand for "manual." Most unix programs and utilities have brief documentation installed on the system. In order to access these online manuals,

Usage: man [program name]

where [program name] is a unix utility or application such as those in this guide.

Note: Not all utilities and applications have "man" pages.


There are many types of files that are commonly used in unix systems that may never be seen by an individual that is only familiar with Windows. The "apropos" utility is a helpful tool for finding the proper utility or application that opens a particular file type. Note that apropos may not be aware of all filetypes.

Usage: apropos [file type] (where [file type] is the file's extension)

Example: apropos pdf

Note: This utility currently works correctly only on linux workstations.


The top utility displays a list of the top ten (default number) programs running

ordered by how much cpu or computing power the programs are using. A user can stop

programs that they started from this screen by pressing 'k' then entering the Process ID (first column number) and pressing enter. In order to quit top simply press 'q'.


The ps utility is another way to display a list of programs running on the system. Just typing ps will display a list of programs that have been started from the particular terminal window that the user is in. In order to see a more useful list of all programs running on the system,

Usage: ps –ef

Example: ps -ef |grep [username] (returns all the processes that are running for [username])


Use this unix utility in conjunction with ps in order to end a running program on the system by the Process ID (first column in ps's output).

Usage: kill [PID]

Example: kill 2458



lpr can be used to print ONLY postscript or flat text files from the command line or from within an applications print dialog.

Usage: lpr –P[printer name]@print [file name]

If you leave out the -P... the file will be printed to the default printer for each lab.

Examples: lpr -Pdcllas1@print myfile.ps lpr -Pehcolor1@print mycolorfile.ps lpr mytextfile


The Acrobat Reader allows users to view and print PDF files. It can be invoked by typing acroread from the command line.

Usage: acroread

Once acrobat is running, the file to be viewed can be chosen by clicking File and Open. Scroll up and down the list to find the desired file, and click on that file to open it.


GhostView? is a program to view and navigate through PostScript? and PDF documents on an X display, by providing a user interface for the ghostscript interpreter. GhostView? can be started by typing gv at the command line.

Usage: gv

Remote Access


Secure Shell is a program to log into another computer over a network, to execute commands in a remote machine, and to move files from one machine to another. It provides strong authentication and secure communications over insecure channels.

Usage: ssh [username]@[workstation name] where [workstation name] is the name of the remote workstation and optional [username] is the username you wish to login with.

Examples: ssh remsun (on the CAL network using your current username) ssh XXXX@metis.astro.columbia.edu (outside the CAL network with netid XXXX)


The sftp utility is the secure version of ftp and works almost identically. Usage: sftp [workstation name] or sftp [username]@[workstation name] (Similar to the ssh command)


Copies a single file or a folder with multiple files using secure protocol over TCP/IP (the network) from one computer to another. This is rarely useful within the CAL environment, since your home directory is mounted on all workstations. However, it may be useful to copy to another machine on or off campus that runs an ssh server.

To copy one file from a remote workstation to your workstation Usage: scp [remote workstation name]:[file name] [local path]

Where [local path] is the location where you wish to save the copied file (the location . is your current location). Similarly, to copy one from your workstation to a remote workstation Usage: scp [local file name] [remote workstation name]:[path]

To copy an entire folder as above respectively Usage: scp –r [workstation name]:[remote directory path] [local destination path] Or: scp –r [local directory path] [workstation name]:[remote destination path]

Examples: scp . user@remotemachine.domain.org:~/myfile scp -r ~/ name@machine:/usr/local/src/ scp -r docs/ user@machine:~/

Please note, the follow remote access methods are unsupported.

  • telnet
  • rlogin
  • rsh
  • rcp
  • rdist

These methods do not use encryption and therefore are not part of EWS's commitment to using secure communication.