Some Useful Unix Commands

This page is intended as a brief list of useful commands to get you started using Unix.

More information about Unix can be found at Temple's Computer Services page Unix Quick Reference.

There's also a nice tutorial on the Idaho Sate web site that provides further information. I'd suggest that you at least look at the explanation of the filesystem structure if you are new to Unix.

Some good books about Unix are:

Unix In A Nutshell, by Daniel Gilly and the staff of O'Reilly & Associates
Learning the Unix Operating System, by Jerry Peek, Grace Todino and John Strong
(Both are published by O'Reilly and Associates)


This page uses the nimbus prompt for the sake of example.
Words enclosed in angle brackets (<>) are arguments supplied by the user.


A Note On Shells

The Unix shell, or command interpreter, provides your working environment on the system. Most systems are set up to allow you to choose the shell you prefer. The default shell on most of the machines in the CIS department here at Temple is csh (c shell). Many people find tcsh (t-c shell) friendlier. It provides a command history using the arrow keys, as well as tab-completion of commands.

If you would like to change your shell from csh to tcsh use the following command:

   
   [nimbus]~% chsh
   Old shell: /bin/csh
   New shell:
Type in "/bin/tcsh" (without the quotes) and hit [Enter].
The next time you log into your account you will have the new shell.
Commands

The two most important Unix commands to know are man and apropos.

   [nimbus]~% man <command name>
This displays the system's manual page for the command. These pages sometimes seem somewhat cryptic to new users, but it's worth the effort to get used to using them.

   [nimbus]~% apropos <keywords>
This gives you a list of man page entries associated with the keyword(s). Use apropos when you have an idea of what you want to do but don't know the name of the command you need to do it.

pwd, cd, mkdir, rmdir

   [nimbus]~% pwd 
Displays the current directory. Some Unix systems are set up so that the current directory (the directory you're in) is part of the prompt.

   [nimbus]~% cd <directory>
Change directory. Takes you to the specified directory. If you don't supply the <directory> it returns you to your home directory.

Unix provides shorthand names for three special directories:

   [nimbus]~% mkdir <directory name>
Make directory. Creates a new directory under the current directory.

   [nimbus]~% rmdir <directory>
Remove directory. Deletes an empty directory.

ls

   [nimbus]~% ls <directory>
Lists the files in the specified directory. If no directory is given it lists the current directory. By default, files beginning with '.' are not listed. These files are usually configuration files.

   [nimbus]~% ls -a <directory>
Lists all files, including those beginning with '.'.
   [nimbus]~% ls -l <directory>
Provides a long listing. Includes file permissions, owner, group, file size, date/time last modified and pathname.

more

   [nimbus]~% more <filename>
Displays a file a screen at a time. 'q' to quit. '/' to search for a pattern.

cp

   [nimbus]~% cp <filename> <filename>
Copies the contents of the first file into the second. Please not that the previous contents of the second (if any) are lost!

mv

   [nimbus]~% mv <filename> <filename>
Changes the name of the first file to that of the second. If both files already existed, the contents of the second are lost.

rm

   [nimbus]~% rm <filename>
Deletes the specified file or files.
Please be careful when using rm. Take a second look before hitting [Enter]. In Unix, when a file is deleted it's gone. That's it. You ain't gettin' it back.
Updated: September 13, 1998

khanna@nimbus