Computational Physics Logo

Gnu/Linux Quick-Reference Sheet

Principal Author: Michael S. Cox
Contributing Authors: J. Lee Burnside and Thomas L. Gibson
(Revised August 17, 2002)

Syntax Notes for This Sheet: Text written in square brackets, [], are options for the command and "filename" means the file you want to use the command upon, for example, if it says "cp filename filename" on this sheet and you wanted to copy the file "spud.txt" to "spud1.txt" you would type "cp spud.txt spud1.txt".

I hope that clears up any confusion on notation. For any command or program, you can consult man pages (see below) or try the command or program name followed by "--help". These will (or will not in some cases) tell you what the command is used for, and how to use it. Most commands come with optional "switches", generally a "-" followed by a letter. These switches allow you to make the program or command do exactly what you want them to do. Most programs and commands come with more switches than you will ever want to use. My advice is to use only the switches you need and understand.

REMEMBER: Back up your work onto floppy or zip disk on the stand-alone machines when you leave.

Command Line System Commands:

apropos [command or program]	Command to search man pages for
				any item of text.

cd [/path or ..] 		Change directory, path is the directory you
				want to go to, or".." moves you up one 
				directory. Equivalent to the similar "cd"
				command in DOS, or "set default" in VMS.

cp filename newfilename  	Copies a file.

latex filename.tex		Invokes the latex2e text formatting package.

ls                		Gives a listing of the files in a directory.

man [command or program] 	Searches the on-line manual pages for
				the command or program named.  Sometimes 
				it is still difficult to find help on
				some subjects. Also try typing the command 
				or program name followed by "--help", 
				i.e. "man ls" or "ls --help".  TRY USING

mkdir [name]             	Creates a directory. 

mv [path/]filename       	Moves a file.  You can use this to rename a 
	[path/]filename		file also.

rm [path/]filename       	Removes a file.  REMEMBER: there is
				no undelete in Gnu/Linux (or any other UNIX 
				I know of).  Please note that the
				switches for rm given in the man page are 
				* or ? in rm instructions can cause MASSIVE
				all the files to which you have write 
				privilege.  Think before you rm!

rmdir [name]             	Removes an empty directory.

nohup [program name] &		Runs a job in the backround.  You can log
                                off after you "run the job nohup", and the
                                program will continue to execute.  The
                                output that would have been printed to the
                                screen will be placed in a file "nohup.out",
                                in the directory in which you executed the
                                command.  If you want to specify a different
                                output file, consult the man page on nohup.

mcopy a:/[path]filename .	Copies a file from a DOS floppy to the hard
				drive, or the reverse is possible.

mdir a:[/path]			Reads the directory listing off of a DOS
Top of Document

Command Line Shells - BASH

The command shell in Gnu/Linux is BASH, the Borne Again SHell. If you don't already know what a shell is, you don't need to change to another one. Bash is the only shell under which you will be allowed to run. If you really think you need to be in another shell come talk it over with Lee Burnside. We'll see what we can do. I am not promising support for other shells.

Bash works well in Gnu/Linux, and no other shell will run everything. Get used to it.

Top of Document

Programming Languages and Compilers

FORTRAN Programming

NOTE: We have no FORTRAN manual available, but there are numerous books on FORTRAN available in the world, so buy one if you're going to use FORTRAN. Doctor Gibson can probably recommend one. My personal favorite is Numerical Recipes in FORTRAN.

g77 filename    		Allows you to compile your FORTRAN
				source file.  The filename should 
				be of the form "mycode.f".  

C Programming

There is online documentation about gcc (the Gnu C Compiler).

On the other hand, if you want to buy a generic C book, I recommend The C Programming Language, by Kernighan and Ritchie (Commonly known as "K-n-R"). Also Numerical Recipes in C is okay for the more advanced C programmer. For a cheap alternative try Programming in C from the Schaums outline series. QUE publishing has published numerous C books which range from good to really stinky.

gcc "filename" [-lm]   		The Gnu C Compiler.  Use the man page for
                                the command line switches for gcc.  The
                                "-lm" switch adds the math libraries.  If
                                you're using a single C file, it's fairly

make           			This is for multi-sourcefile
				projects. It requires a "makefile",and 
				you have to write this yourself.  Writing a
				makefile is not a trivial process, and 
				I do not recommend it for the uninitiated.

C++ Programming

There is also a g++ (Gnu C++ Compiler) available.

g++ -o "file" "" 	The Gnu C++ Compiler.  Use the man page for
                                the command line switches for g++.

Top of Document


joe [filename]           	Joe's Own Editor. An easy text editor,
				similar to wordstar.  Filenames for text 
				files need not end with ".txt", or any
				extension for that matter, and "ctrl+k" 
				pops up the menu for the editor. "ctrl+k" 
				followed by an "h" brings up help.

vi [filename]     		The most common text editor on Unix systems.

xedit				An X-based editor, mouse driven etc.

xemacs [filename]         	Still more editors.  This one is a highly 
				developed, graphically based editor, 
				with lots of built-in functions. It is 
				popular among the Unix community.

xjed [filename]        		Another text editor that is quite
				easy to use.  "ctrl+h" brings up the menu 
				bar at the bottom which tells you all you 
				need to know.
Top of Document

X Windows, The Graphical User Interface

GUI's - pronounced "gooeys" - are available on the Gnu/Linux stations. They allow you to use more friendly applications and access to the NET (a.k.a. the Internet, a.k.a. The Information Superhighway, a.k.a. the Infobahn, a.k.a. The World Wide Web -- THE NET). The applications that run under X-Windows are fairly self-explanatory so I only mention them briefly here.

xmaple				A highly sophisticated package for doing
				symbolic or numeric mathematical operations.
				This package has nice built-in graphics that
				can be exported as a PostScript file.  The
				option to save your output as a LaTeX file
				also exists.

xmgrace				An excellent interactive 2-d plotting
				package.  Import files to be plotted as
				a set of (x,y) or (x,y1,y2,...,yn) points.

gnuplot				Another good plotting package for 2-d and
				surface plots.

konqueror			The best browser on the market.

mozilla				Another excellent browser.

kghostview			A way to preview a PostScript file--saves
				printing ones with mistakes.

lyx				Graphical LaTeX-based word processor.

openoffice			This is the Gnu/Linux version of the popular
				word processor.

NOTE: Everyone has to use these machines, so please don't change colors etc. in X windows. Also, if something goes wrong, like if the machine locks-up or you end up with a process (a command or program) that you cannot terminate, call one of us to try to find the best fix for the problem.


Top of Document

Closing Statement

Okay, so that's a short form of the commands and programs available to you. UNIX is by far the most common operating system at institutions and corporations of any size. The only system more common is Windows. Keeping this in mind, it makes sense for all of us who want to ultimately work in universities or the private sector to learn to use UNIX.

As far as documentation goes there are a significant number of links on Dr. Gibson's Computational Physics page. If these don't make you infinitely happy, and make your corporeal existence a utopian nirvana---you might want to purchase Linux in a Nutshell, available at Barnes and Noble, or some other generic Gnu/Linux/UNIX books.

				Michael S. Cox ==|:-)#
Top of Document

This page designed and maintained by t.l. gibson

Page last modified September 3, 2002

Return to Gibson Home Page