Unix Commands

The commands described in this document relate to the Computer Science Department's Unix system called Hercules.

Command Format

Unix commands are intentionally short, often only two or three characters in length, in order to minimize typing.

The general format for a Unix command is:

	cmd -options other arguments

where "cmd" is the name of some command followed by a number of options or other arguments.

Options are generally single characters that represent specific options. The minus sign "-" should be entered before an option. Observe the format of the option in the "man" command in the following table.

Unix is case-sensitive, so be sure you enter the options and arguments in the proper case. Generally lower case is used for commands.

Dot Files

There is a standard set of configuration files for your Unix account in the Computer Science Department. These are the so-called "dot" files, because they begin with a dot - i.e. a period. To see all of your files (including the dot files), enter the command: ls -a

So what happens if you accidentally delete one of these files?
Well, you might find the system acting strangely. For example:

A possible solution to problems like this is to copy the default set of dot files back into your account. The command to do this is:
To ensure that all of the newly copied dot files are executed, you should logout and then login again. If this does not fix up your problems, consult your lab instructor who may in turn consult the systems administrator.

Basic Commands

A few commands you should become familiar with:

cd path

change directory.

cp path1 path2

Copy file(s).

chmod permissions path

change the mode, the permissions, on a file or directory.
chmod 755 file sets the file permissions to: rwx r-x r-x
            Owner read, write, execute
            Group read, no write, execute
            World read, no write, execute
chmod 700 file sets the file permissions to: rwx --- ---
            Owner read, write, execute
            Group no read, no write, no execute
            World no read, no write, no execute
(Binary bells should be ringing in your head by now.)


call up the "ftp" (file transfer protocol) program.


to get a listing of files in a directory
ls -l gives a long listing, showing permissions.

man command

to get a Unix Manual entry for a command.
e.g. man passwd

man -k topic

use the -k option to find all the entries for a specific topic.
e.g. man -k password

mkdir path

make a directory

more file

more prints file to the screen and pauses the output when the screen is full. You can view the next screenful or just the next line. Look for the instructions at the bottom of the screen. Enter q to exit more. For help type h
command | more When the command is executed | passes its output to more which pauses the output when the screen is full. You can now treat the output like a file as above.

mv path1 path2

move file(s). The original file is deleted.


change your Unix password.


call up the "pine" mail utility.


print working directory, i.e. show current path.
In other words: where am I in the Unix file system.

rm path

to delete (remove) a file

rmdir path

to delete (remove) a directory.

script file_name

cause everything that appears on the screen to be placed in the file_name.
Turn this off by entering ^d (control-d).

TeraPrint file_name

Send the file to whatever printer is designated as your default Windows printer.
e.g. In CL135.4 this will print your file in CL135 IF you have enabled printing from the PC.
Note: If you issue this command from your home PC, it will send the file to your home printer.

Example of Use

The following illustration explains how to use several of these Unix commands to create a "Home Page" that can be viewed as an Internet World Wide Web file.


Ensure that you are in your home directory.
(If it does not get any arguments, "cd" assumes your home directory.)

chmod 711 ~/

Change the mode of your home directory to make it world readable.
711 sets permissions: (rwx --x --x)
Owner has "rwx" - read, write, execute permissions;
Group has "--x" - execute permission only;
World has "--x" - execute permission only.
The tilde character "~ indicates your username.
The slash character "/ indicates your home directory.

mkdir public_html

Make a directory called "public_html"; notice the underscore character.

chmod 711 public_html

Make public_html world executable.

cd public_html

Change your location to the public_html directory you just created.


Print the current working directory just to make sure you are where you want to be.


Use an editor to create a file called index.html or copy a sample file from another location.

ls -l

Get a long listing of your current files. If you had used vi to create the file, you will see something like this:
-rw------- 1 user_name your_group 12 Apr 15 10:00 index.html
This means that you, the owner has read and write permission, and that everyone else is excluded.

chmod 644 index.html

Change the file mode so that others can read the file.
644 sets permissions: (rw- r-- r--)
Owner has "rw-" - read and write permissions;
Group has "r--" - read permission only;
World has "r--" - read permission only.

ls -l

Get a long listing to make sure the file permissions are set properly.

For more information on these, and other Unix commands, refer to the 4.6 UNIX System section of the CS Dept Users Manual.

For information on the vi editor, refer to the 5.2. VI EDITOR section of the CS Dept Users Manual.

The Users Manual can also be accessed from the CS Dept Home page, following the links: General Info - Lab Manuals.

Copyright: Department of Computer Science, University of Regina.