In this section, some simple forms of a few Unix commands will be outlined. If you want to know more about Unix commands, there are many good tutorials available in bookshops and on the WWW. If you install Linux, your CDROM or book should have some tutorials.
turing % who jdoe ttyp0 Sep 02 09:16 fflintst ttyp3 Sep 17 15:45 ddawg ttyp2 Sep 04 11:41 sdoo2 fluke:0 Sep 17 10:11 norm ttyp7 Sep 17 16:22 comp131 ttyp8 Sep 17 15:43 comp284 ttyp5 Sep 10 15:29 ltorvald ttyp6 Sep 16 15:57 wflintst ttyp9 Sep 05 17:20 brubble erdos05:0 Sep 17 15:53
turing % w 14:21 up 16 days, 5:34, 10 users, load average: 1.42, 1.50, 1.44 User tty from login@ idle JCPU PCPU what jdoe p0 boole 09:16 26:41 139:41 7 -zsh fflintst p3 bedrock 13:52 5 5 talk brubble ddawg p2 fermat 11:41 1:40 8:32 6 -tcsh sdoo2 p7 fluke 14:16 2 vi file.h norm p8 gumby.une.edu.au 15:43 2:07 11:32 1:03 ncftp ftp.sun comp131 p5 germain 15:29 23:44 -csh comp284 p6 godel 15:57 23:13 -tcsh ltorvald p7 kernel 16:22 gcc wflintst p9 riemann 17:20 16:53 3:42 3 -tcsh brubble pa bedrock 13:52 talk fflintst
turing % whoami fflintst
turing % date Tue Sep 16 17:07:26 EST 1997
turing % ls Deb cshrc.csh dat4.Z hons private
Some Unix commands may take option flags which alter the way the command works. These flags are usually optional. For example, the basic form of ls is demonstrated above. However, if the command is given with the option -l (for long), the command prints as shown below:
turing % ls -l total 64 drwx------ 2 fflintst 1024 Nov 20 09:34 Deb -rwxr-xr-x 1 fflintst 580 Nov 16 00:55 cshrc.csh -rw------- 1 fflintst 1101 Sep 29 13:05 dat4.Z drwxr-xr-x 3 fflintst 1024 Jan 4 11:45 hons drwx------ 2 fflintst 1024 Jan 29 11:29 private
The option -a (for all) lists all files including `invisible' files. You can also combine options. For example: ls -la.
Some Unix commands take command line arguments which may be either optional or mandatory. For example cal prints out a calendar for either a month or a year, but MUST be given the year of the calendar that is required.
turing % cal usage: cal [month] year turing % cal 12 1957 December 1957 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Many Unix commands accept both arguments and flags. For example, if ls is provided with a list of files, it will only return information on those files that exist.
turing % ls cshrc.csh not.here cshrc.csh turing % ls -la cshrc.csh not.here -rwxr-xr-x 1 fflintst 426 Oct 9 14:45 cshrc.csh turing % ls Deb cshrc.csh dat4.Z hons private
Assume that in your home directory there's a file called test1. The examples below will manipulate this file with the cp (copy), mv (move), and rm (remove) commands.
Makes a copy of sourcefile which is then named destfile. For example, to make a copy of test1 called mycopy:
turing % cp test1 mycopy
If you now do an ls, you should have two files, test1 and mycopy.
Renames, or moves sourcefile to destfile. For example, to rename mycopy to newcopy:
turing % mv mycopy newcopy
Again, do an ls to check your result.
file. For example, to remove newcopy:
turing % rm newcopy
Note that once a file is removed, it is gone. There is no `un-remove'
feature. Some Unix systems however, provide
These commands are used to move around, create and delete directories.
turing % pwd /user/fflintst
turing % cd ../brubble
changes up one directory, and then down into brubble. If you enter
turing % cd
you will be back to your home directory, i.e., the directory where you are when you first login. This is the default behaviour of cd. This is, if no directory is specified, it changes directory to your home directory. Try:
turing % cd .. turing % pwd /user turing % cd turing % pwd /usr/fflintst
A very useful abbreviation13 which means `home directory of', is
For example, if you typed
cd ~brubble you would change directory
to the home directory of user brubble. A
~ by itself just means
your home directory. So the commands
cd ~ do the
See also Section 5.8 where it is explained how to
~ to find the various unit home directories on UNE systems.
turing % mkdir tute1dir
turing % rmdir tute1dir
If you try to remove a directory that contains files, you will be given an error message.
The standard command with which to display a file.
turing % cat file1
If a file is longer than one screen, you will probably want to use less instead. It displays a file one screen at a time.
less14 will display the first page15 of a file and
then wait until the user instructs it on what to do next. Some
of these commands are:
|RETURN||move display down one line|
|b||move display back one screen|
|SPACE||move display forward one screen|
|q||quit displaying the file|
These commands show you how to print files on UNE systems. If you are an external student, there is no point in printing files on these printers as you cannot collect the output. If you run Linux on your home system, then these commands will be similar to the ones you will use on that system.
Queues file to be printed on the default printer. The option -Pprintername sends the file to the queue on printer printername. For example, lpr -Pmlab1 file sends file to the printer mlab1.
turing % lpr file1 turing % lpr -Pmlab1 file1
The amount of time it takes for your file to be printed, depends on the size of the queue before it. To find out the size of a printer queue, use lpq for the default printer, or lpq -Pprintername for printer printername.
turing % lpq mlab1 is ready and printing via network Rank Owner Job Files Total Size active fflintst 80 file1 733 bytes
A copy of the Unix manual is kept on the system, and it is possible to have the documentation for most commands displayed by the man command. The example below illustrates how to use man to display the documentation for the cat command. This example has been truncated.
turing % man cat cat(1) NAME cat - Concatenates or displays files SYNOPSIS cat [-benrstuv] file ... | - The cat command reads each specified file in sequence and writes it to standard output. [deleted]
Man pages are intended to be a comprehensive reference for most Unix commands. They are not intended as tutorials and as such can be hard to understand for novice users. As your experience grows, so too will your appreciation for man pages.