Top 10 UNIX Commands
Contents
1.
man
2.
ls
3.
cd, mkdir
4.
rm, rmdir
5.
cp
6.
mv
7.
lynx, netscape
8.
pine, pico
9.
finger
10.
host / dig
 

Please note:
  • Text that appears in a typewriter style is used to show commands that you can type.
  • Text that is in square brackets, [ ], indicates a set of options that can be used with a command.
  • The commands referred to here will work on Unix systems operated by Information Serivces and Technology at the University of Manitoba. Some of these commands may work differently or may not be available on other Unix systems at the University or at other locations.

1. "man"   Display Manual Pages

The man command will display the manual pages for most UNIX commands. For more information on any of the Unix commands below, use this to see if there is an online manual page available. For example, if you require help on the move (mv) command, you would type:

    man mv 

The command syntax for man is:

    man commandname

By default, the man command uses another command called more to display the manual page one screenfull at a time. To display the next screen, press the space bar. To end the display before the end of the file, press the "q" key.

The Unix man pages are also available on-line from the Suns Document Pages.


2. "ls"   List the contents of a directory

Use this command to list the contents of the current directory. This will display all files and directories within the current directory in a columnar format.

You may change the format in which ls displays your directory listing by adding options to the ls command. To add an option to the command, follow the ls command with a minus sign '-' and the option(s) you wish to add. For example, ls -l will list the current directory in long format, showing size, date, and permissions. ll is a common alias or shortcut for the list long command (ls -l).

In Unix, there are files which are normally hidden called "dotfiles". These dotfiles are files that start with a dot (i.e. a period - ".") and are used by programs and shells to retain control information such as preference settings and bookmarks. To see hidden files, use ls -a to list all files, including those files whose names begin with a period. Be careful not to remove dotfiles if you're not sure of their purpose.

The command syntax for ls is :

    ls [ -aAcCdfFgilLqrstux ] filename  

If you use the ls command on a directory with many files, the display will probably scroll off the screen. To avoid this, you can "pipe" the display through the more command, just as with man pages. The Unix "pipe" symbol is a vertical bar (often a broken vertical bar on your keyboard). It means "take the command on the left, and use it as input to the command on the right". For example:

    ls -la | more  

Which lists the content of the current directory, in long format (-l) and includes all files (-a), and sends the listing to the more command which displays the listing one screen at a time.

For more complete information on the ls command, try man ls.


3. "cd" - and
    "mkdir"
  Change Directory
Make Directory

The "change directory" command is used to switch from one directory to another. The purpose of having multiple directories is to enable you to easily organize your files. Your directory structure should resemble a filing cabinet, with folders (directories) for each set of files.

Using cd without a directory name following it will always return you to your home directory, no matter where you are in the Unix directories. To change to a subdirectory, for example one called "skiing", you would type:

    cd skiing  

To "back up" a level in the directory structure from a subdirectory to its parent directory, you can use:

    cd ..  

.. is a special directory which always links a directory backwards to its parent directory, you can see this directory with the ls -a command. There is a second special directory called . which always refers to the current directory.

The command syntax for cd is :

    cd [directoryname]  

For more complete information on the cd command, try man cd.

The "make directory" command is used to create a new directory. As noted above, a directory serves to organize files in a manner to similar to a filing cabinet. However, unlike most filing cabinets, a single directory may contain several subdirectories. For example, to create a directory called "Banff":

    mkdir Banff  

The command syntax for mkdir is:

    mkdir directoryname  

For more complete information on the mkdir command, try man mkdir.


4. "rm" and
    "rmdir"
  Remove files
Remove Directories

The "remove" command is used to permanently delete your files from your directories. To remove a file named "whistler.ps" from the current directory:

    rm whistler.ps  

To remove multiple files, use the remove command followed by the names of the files, separated by spaces. For example:

    rm file1 file2 file3  

The command syntax for rm is:

    rm [-fir] filename  

The "remove directory" command is used to delete your directories. The directory you wish to remove must be empty before using the rmdir command. To remove a directory called "bigsky", you would type:

    rmdir bigsky  

The command syntax for rmdir is:

    rmdir directoryname  

To remove a directory that is not empty (and all of its contents) you can use the rm command with the -r (recursive) option. This will recursively remove all files from a directory (or subdirectories) and then remove the directory itself. Repeating the previous example:

    rm -r bigsky  

For more complete information on the rm and rmdir commands, try
man rm, man rmdir.


5. "cp"   Copy files

The "copy" command is used to make a copy of a file in the same or a different directory. If copying to the same directory the filename of the copy must be different. This is useful for making backups or working copies of files while leaving the originals alone. To copy the file tahoe.txt to a backup file tahoe.txt.bak in the same directory:

    cp tahoe.txt tahoe.txt.bak  

To copy the file named "tahoe.txt" from your home directory to a directory named "goodskiing" (without changing the name):

    cp tahoe.txt goodskiing  

If you wished to rename the copied file:

    cp tahoe.txt goodskiing/newname.txt  

The command syntax for cp is:

    cp [ -ip ] filename1 filename2  

For more complete information on the cp command, try man cp.


6. "mv"   Move or Rename Files

The "move" command is used to move or rename files.

For example, to move a file named "panorama.ps" from your home directory to a directory named "goodskiing", you would type:

    mv panorama.ps goodskiing  

The "move" command can also be used to rename files or directories. If you wanted to rename a file called "mammoth.ps" to "BIG.ps" (remember that UNIX is case sensitive!), you would type:

    mv mammoth.ps BIG.ps  

Finally you can move and rename at the same time by specifying a new file name along with the directory to move to:

    mv mammoth.ps goodskiing/BIG.ps  

The command syntax for mv is:

    mv [ -fi ] filename1 filename2  

For more complete information on the mv command, try man mv.


7. "netscape"and
    "lynx"
  Browse Information on the World-wide Web

Netscape and Lynx are two web browsers available on the Unix system. Netscape offers a graphical interface most familiar to browsers on other systems, while Lynx offers a text only browser interface. Lynx can be useful if you want quick access to information, or are using a text based terminal.

To start Netscape you must be logged into the CDE. Then type netscape at any Unix prompt, or click on its icon in the workspace menu.

To start Lynx type lynx in any Unix session. By default Lynx will startup displaying the U of M's home page. If you wish to have lynx browse a certain page once it starts, you can type:

    lynx URL  

For specific information on running lynx try How to View the Web in Text Only with Lynx.


8. "pine" and
    "pico"
  email and text editing

Typing pine at the UNIX prompt will start up a simple but effective text base mail program. Pine allows you to receive, compose, send and organize e-mail messages, corresponding with anyone around the world who is connected to the Internet.

Messages composed in Pine are editted using a file editor program called "pico" (for PIne COmposer). The command pico can also be used from the UNIX prompt to create and edit other files. By default, pico will break up long lines between words, which gives a better appearance in most mail-reading programs.

To create a file called "filename" with pico type:

    pico -w filename  

Pine and Pico both have help features. For a more extensive introduction on UNI programs, see the UNIX Software section. 


9. "finger"   Get Information About Someone On Unix

Finger is used to display information about users on UNIX systems. Finger displays a user's full name, last login, and when the user last read their mail. If you wished to find out information about a user on campus, you would type finger user_name. If you wished to finger a user on the Internet, you would type finger username@host. You can also enhance the operation of finger by appending options to the finger command. For instance, if you know the person's full userid, you would then type finger -m username, which is much quicker than the normal finger command.

The command syntax for finger is:

    finger [-mlsqibfwhp] [username]  

For more complete information on the finger command, try man finger.


10. "host"   Get Information About a Host Machine

Although old, the host command lets learn about a machines 'host' information.

"dig"   Get Information About a Host Machine

Although old, the dig command lets learn about a machines 'host' information.


Additional Information
  • If you do not know the name of a file, but part of the name, you can use the * to signify the unknown part of the name. For example, to remove every file that ends in .ps, you would type rm *.ps
  • UNIX is case sensitive!
  • Academic Computing and Networking sometimes offers introductory courses on UNIX. For information see: umanitoba.ca/ist/training
  • The Campus Bookstore has Dr. Salomon's Unix Cookbook, a great quick reference available for purchase

IST SERVICE DESK

Mon - Fri: 8am to 8pm
204-474-8600 or
Chat Now button with link

Walk-In:
Fort Garry
123 Fletcher Argue
Mon - Fri: 8am to 8pm

Bannatyne
230 Neil John Maclean Library
Mon - Fri: 8am to 4:30pm

New! Submit requests & check ticket status online at: umanitoba.ca/ist/service_catalogue/