Basic Unix Commands

The following commands are categorized by type or function. These are the minimum required to get you going; it is far from a complete list of all Unix commands.

Navigating Directories and Files

Files on a UNIX system are grouped into directories and subdirectories in a hierarchical structure. The use of a path statement is how files and directories are accessed.

   pwd      'print working directory' displays the name of the current directory 
   cd       'change directory' command will change the current directory to the 
            directory specified as the argument to the command, as in  
            'cd /home/WWW-pages/username'. ('cd' without specified parameter 
            will return to your home directory.) 
   ls       'list files' command displays the files in a directory. 
   ls -l    'long list option' for listing files displays permissions, links, owner, 
            group, file size, modification date, file name. 
   rm       'remove' command deletes ordinary files in a directory. 
   mv       'move' command moves a file from one location to another. It is also used 
            to rename files, as in 'mv thisfile.txt thatfile.txt' 
   cp       'copy' command creates a copy of a file. 
   chmod    'change mode' command is used to control access rights to a file or files. 
   mkdir    'make directory' command creates a directory or subdirectory within the 
            current directory. 
   rmdir    'remove directory' command removes a directory or subdirectory. The specified 
            directory must be empty before it can be removed. 
   find     'find' command is used to locate files. 
   file     'file' command is used to determine the type of information in the file 
            listed as the argument to the command, i.e. text or binary. 
   cat      'cat' command displays the contents of files. It is also used to concatenate 
            files as in "cat file1.txt file2.txt file3.txt > allfiles.txt". 
   wc       'wc' command displays a count of characters, words, and lines in a text file. 
   sort     'sort' command is used to sort and/or merge text files. 
   grep     'grep' command searches for text strings in files. 
Back to command index

Connecting to Other Systems

   telnet   'telnet' connects to remote computer. At the $ prompt, type 
             'telnet hostname' where hostname is the remote computer. 
             For example, 'telnet' is how to initiate a  
             telnet session on Student from any of the labs on campus. 
   ftp      'ftp' connects to FTP site on remote computer and allows you to transfer 
             files from your local machine to the remote computer or vice versa. 
             The syntax for 'ftp' is the same as for 'telnet'; 'ftp hostname'. 
   mutt      'mutt' initiates mutt e-mail reader. 
   logout   'logout' terminates connection to remote system. (Can also use 'bye'). 

NOTE that when using the computer labs on campus, check with a lab assistant for specific applications that can be used for connecting to, and transferring files to and from other systems.

Back to command index

What's Going On Commands

   date     'date' displays the current date and time. 
   who      'who' displays a list of users who are currently logged in. 
   finger   'finger' is similar to 'who', but displays more information, 
            i.e. user name, login time, login location. 
   ps       'ps' displays a list of the processes (programs) that you are 
            currently running. 
Back to command index

Basic VI Commands

Vi is the default editor for the "elm" mail reader. It is a good idea to familiarize yourself with vi before attempting to use elm. For a mail reader with a menu-driven interface, use pine.

Opening and Exiting Commands

   vi            Invokes vi with blank editing screen (new file) in command mode. 
   vi filename   Invokes vi on existing file. 
   :w            Writes (saves) existing file (command mode only; <ESC> from insert mode). 
   :w filename   Writes (saves) to new file (command mode only; <ESC> from insert mode). 
   :x            Writes (saves) file and exits vi (command mode only; <ESC> from insert mode). 
   :q            Quits vi without saving (command mode only; <ESC> from insert mode). 
   :q!           Quits vi without saving any changes to file (command mode only; 
                 <ESC> from insert mode). 

Movement Commands

   h        Move cursor left one character. 
   j        Move cursor down one line. 
   k        Move cursor up one line. 
   l        Move cursor right one character. 
   w        Move cursor forward one word. 
   b        Move cursor backward one word. 
   e        Move cursor to end of word. 
  ^F        Move cursor forward one screenful.(Hold CTRL key and press f) 
  ^B        Move cursor back one screenful. (Hold CTRL key and press b) 
  ^D        Move cursor down half screenful. (Hold CTRL key and press d) 
  ^U        Move cursor up half screenful. (Hold CTRL key and press u) 

Editing Commands

   i        Insert mode; inserts text before current cursor position.    
   I        Insert mode; inserts text at the beginning of the line. 
   a        Insert mode; append text following cursor position. 
   A        Insert mode; append text at the end of the line. 
   o        Open a new line below the current line and insert text. 
   O        Open a new line above the current line and insert text. 
   r        Replace character under cursor. 
   R        Overtype mode; <ESC> terminates overtype. 
   s        Substitute following text for character at cursor position; <ESC> terminates 
            text entry mode. 
   S        Substitute text on entire line. 
 <ESC>      Return to visual command mode from insert mode. 
   x        Delete character at cursor position. 
   X        Delete character before cursor. 
   dw       Delete word at cursor position. 
   dd       Delete current line. 
   d$       Delete from cursor to end of line. 
   d^       Delete from cursor to beginning of line. 
   cx       Change text object at cursor positon. x is a cursor movement key, commonly c 
            (line), w (word), b (back one word), $ (to end of line), ^ (to beginning of line). 
            <ESC> terminates text entry mode. 
   ym       Yank (copy) text block identified by movement command m. (See above) 
   Y        Yank (copy) current line. 
   p        Put yanked text after or below cursor. 
   P        Put yanked text before or above cursor. 
   .        Repeat last edit. 
   u        Undo last edit. 
   U        Restore current line. 
NOTE that is it important to type carefully when using vi. Since vi commands are case sensitive, you DO NOT want to accidentally turn Caps Lock on. You will get unexpected results.

Back to command index

Return to Student Home Page

CWIS Home Page

Questions or comments about Student may be sent to: