next up previous contents
Next: Editing files under Unix Up: Using the computers! Previous: Shells and login scripts   Contents

Common Unix Commands

This section documents common Unix commands. They are fundamental and should be implemented almost identically on any Unix platform. (Be aware, however, that different operating systems may expect different command-line arguments and produce different formatted output). See Table 3.

If you which to use GNU tools you may need to put /usr/local/bin, /usr/bsd/ or /usr/freeware/bin in your path.

Table 3: Summary of Common Unix Commands
Command Basic syntax/Example More info...
cd cd directory 'cd' changes your current directory. You can specify the directory to change to in two ways -- using relative or absolute paths. Relative paths use two special directories -- '..' refers to the directory above the current one and '.' refers to the current directory. Absolute paths have a leading reference to the root directory -- '/'. cd with no parameters returns you to your home directory.
pwd pwd 'pwd' prints the current (''working'') directory.
mkdir mkdir directory 'mkdir' creates a new directory with the nominated name (provided an existing file or directory with the same name does not already exist).
cp cp source destination 'cp' is used to duplicate a file. If you want to copy every file in a directory and its sub-directories then use 'cp -r directory new-directory'
exit exit 'exit' exits the shell you are currently running.
logout logout 'logout' logs you out of the login shell you are currently using.
man man name man is used to get help on a command or topic. Type 'man man' for more information on man :-)
info info name info is used to get help on a command or topic using a hierarchical viewer. Type 'info info' for more information on info.
ls ls 'ls' displays a listing of the current directory. By default files beginning with the '.' character are hidden. To have these files included in the listing use the '-a' option. The '-l' option displays more information on each file. An extremely common use of the command is therefore 'ls -alF'.
mv mv source destination 'mv' is used to move a file. The mv command is used with exactly the same syntax to move a directory as to move a file.
rm rm filename 'rm' is used to remove a file. If you want to remove every file in a directory and all directories within it then use 'rm -r directory-name'
more more filename 'more' is used to view a long document one screenful at a time. (Press spacebar to scroll down and 'q' to quit.)
less less filename 'less' is used to view a long document one screenful at a time. It has many more features than the 'more' command. You can set 'less' to be your default pager for 'man' pages by exporting the variable $PAGER equal to less from your shell.
chmod chmod flags filename 'chmod' is used to record in a UNIX filesystem what types of users can access your files and in what way. Read the 'chmod' man or info pages to gain an understanding of file permissions.


next up previous contents
Next: Editing files under Unix Up: Using the computers! Previous: Shells and login scripts   Contents
The University Computer Club