Information about UNIX operating system

Useful commands

These are commands that can be entered from the system prompt for managing files and directories. Please refer to the Emacs Directory Editor for an easier way to execute these commands.
Changing password
Use the yppasswd command to change your password on ocelot.
Deleting files
The command for deleting a file is rm -i. The -i option has the computer prompt you before deleting, just to be sure you didn't request deleting all files.
Copying files
The command for copying files is cp. You can include full path names for the files (eg, cp ~downeyt/cbin/ada.emacs .emacs).
Moving (renaming) files
The command to move (rename) a file is mv (eg, mv prog.adb old_prog.adb).
Creating a new directory
You can create a new directory with the mkdir command (eg, mkdir progs).
Changing directories
The command for changing to another directory is cd. The ~ is a shorthand for your home directory, so cd ~ will always return you to your home directory. You can try to see someone else's home directory with cd ~username (eg, cd ~downeyt).
Directory listing
To see a listing of the files in your directory, use the ls -l command. The -l is for a long listing, including size, date, access rights. You can also call ls without any options for a shorter listing.

Back to Index


There are a several editors on the UNIX system, nano , emacs, and vi. They should all be available on the school systems, if not then send me an e-mail message.

nano has a simple menu system that explains itself.
To start nano, issue the command

Word wrapping can corrupt configuration files. To disable word wrapping in nano, start it with the -p switch.

	nano -p
emacs is an editor and an operating environment.
To start emacs, issue the command
There is a tutorial for emacs that you can run to familiarize yourself with some of the major features. To start the tutorial, first call up emacs , then issue the command
The most important command to learn is how to exit emacs
        CTRL-X CTRL-C
I have also created a short list of most frequently used emacs commands.
vi is a very good editor, but is not an operating evnironment like emacs. For text editing, you might like vi. If you need to edit a lot of different files at the same time, then I recommend emacs.
To start vi, issue the command
For a tutorial, check out the Mastering the vi editor

Back to Index

Printing files

The command for printing a file on UNIX is lpr. It has an option named -P that specifies the printer, and an option named -J for the name to appear on the front banner of the printout. For example
	lpr -Pipc414 -Jdowney prog.ext

This will print in room PC414 with downey on the banner.

You can place the following in your .cshrc file

	setenv PRINTER ipc414

then you can omit the -P parameter to lpr. This sets your default printer. You can still override this with the -P parameter.

If your file has more than 1 page of output, then you can send your file through the pr command (pretty). This will insert a page break every 66 lines, and include the date, page number, and name of the file at the top of every page

	pr -fs prog.ext >

then use lpr to print

Back to Index

.cshrc file

The .cshrc is a file that is run automatically when you start a shell on a UNIX system. Place commands in this file that you want executed everytime you start a new shell. You should have a .cshrc that was created for you automatically. You can test to see if you have a .cshrc file by using the command
	ls -a .c*

and looking in the directory listing for .cshrc.

If you do not have a .cshrc file, then you can use the following command to copy a default .cshrc to your home directory.

	Only do this if you do not have a .cshrc file

Here is an example of what might be placed in .cshrc.

	setenv PRINTER ipc414

By placing the above command in .cshrc, you can omit the -P parameter from the lpr command:

Back to Index

Creating a listing to be handed in

When handing in an assignment, I would like to see a copy of all the output on your terminal when you compile, link, and run the program. This listing should include all the input and output to the program as well as a listing of the complete program. The command to do this is script.

When you run script, a new process is created. All information that is displayed on the terminal in this process is also copied to a file called typescript in your original process. Once inside the subprocess, you would issue the commands to compile, link, and run the program (Ada, C), then you would use the cat command to display the contents of the program source files. When you are done, you press CRTL-D to exit the subprocess, then you can print the typescript file using lpr.

	lpr [options] typescript

The default file is typescript, but it is possible to use any file by including it in the script command.

	script file

You would also include the file when printing

	lpr [options] file

Back to Index

You are visitor number to visit this page since 08/09/04.