A simple UNIX cheat sheet from Professor Ortiz  ( Shhhhhhh!!! )

    Much more complete unix primer can be found here.


Background
Basic Commands



Some background

Unix is primarily a command line driven operating system.  This differs from the graphical
interface that you may be used to working with on either the Mac or Windows OS. As
time goes by, unix is becoming more graphical in nature. This can best be see in the
latest unix variant, Linux.

Advantages of unix over other OS systems include:

    1. Superior memory management.
    2. Scalability - runs seamlessly on computers with variable numbers of cpu.
    3. Greater security through advanced system administration.

Disadvantages of unix relative to other OS systems:

    1. less advanced graphical user interface.
    2. less sophisticated printer interface.
    3. higher cost of operation.

May of these disadvantages are fading away as traditional unix companies respond to
advances in other OS systems, and as Linux development brings unix to the mainstream.

Back to top


Basic Commands

File structure

The unix file structure is based on a tree much like the windows explorer or the MacOS
finder. Files are stored in folders called directories.  A series of directories that leads you
to a file is called a path. The base of the tree or root is called the home directory.  It
is designated: /home. Each user has a home directory. The path to your home directory
is /home/<username>, where username is you login name.

Login

To login, type your user name and password at the login and password prompts.

Getting around the tree

ls (alias for "ls -a") - lists the contents of a directory, names only
ll  (alias for "ls -l")   - long listing of the contents of a directory, names,
                               permission and size
cd                        - change directory to the home directory
cd <dir>               - change directory to the specified directory

Operating on files

mv <file1> <file2>                - rename a file (or directory)
mv <file> <dir>                    - move a file (or directory) inside another directory
cp <file1> <dir>                   - copy a file to a new directory
cp -pr <dir1> <dir2>            - move directory 1 and its contents inside
rm  <file> (alias for "rm -i")    - remove a file or directory
textedit <filename> &         -  edit a file using a graphical "textedit" editor
vi <filename>                       - edit a file using the command line editor "vi"

Help

man <command name> -  Provides you with info on how to use a command, but
                                             you must know the name of the command to get help.

Search commands

grep < expression > -  grep will search for a string or expression within each file within
                                    a directory.

Memory Management

ps -elf                                - list processes by username, process id with additional info
jobs                                   - lists all processes running in background
kill -9 <pid>                        - terminate a process identified by the process id number

Other operators

&  - run a process in background
| pipe or redirect output from one command to another command.

Compound commands

ps -elf | grep matlab    - list all matlab processes that are running.

Log off

Before logging off, check to make sure that you don't have any matlab processes
still running.  do this using the command "ps -elf | grep matlab". If you find a command,
you can kill it using the kill -9 <pid> command.

Back to top