MINIMAL LINUX

There is a much more complete linux tutorial on the course website, and, or course, many others on the www. Here I want to present a minimal set of linux commands which will get you through Physics 115B.

What do you need to know?

[1] You need to be able to type programs into a file. So, you should learn the vi editor (or an equivalent). See the course website for several tutorials.

[2] You need to compile your program. Assuming it is called heisenberg.c, you can compile by typing

gcc heisenberg.c

Your executable will be called a.out. I prefer the slightly more complicated

gcc -o heisenberg.e heisenberg.c

which gives the executable a name which matches up with the C code. This is convenient because (i) it doesn't overwrite other executables which already have the default name a.out; and (ii) it is easy to see which executable is associated with which C program.

[3] To run your program, simply type

./heisenberg.e

[4] To print your program (to hand in)

lpr heisenberg.c

[5] To make plots, you can use any graphics package you like. See the course website for xmgrace.

That's it, really! Type in program, compile, run, print, make plots.

A BIT MORE LINUX

Your life will be easier in the long run if you learn a bit more linux. There is a tutorial on the course website and many on the web. Here is my short list of useful commands.

ls: lists all the files in your directory

rm: when followed by a file name, deletes (removes) the file

mv: when followed by an existing file name and a new filename, renames (moves) the file.

When you run a program you can redirect any output that would have come to the screen to a file (eg hermione.dat) by using ./heisenberg.e > hermione.dat. Note that anything that would have come to the screen, eg prompts for input etc, will get redirected to the file. You can put inputs into a file and then read them in by using ./heisenberg.e < granger. This is useful if your program has a long list of inputs and you are just changing one at a time. (You change the one input in granger and that's all.) You can combine these steps with ./heisenberg.e < granger > hermione.dat.

mkdir: when followed by a name of your choosing, creates a subdirectory. You might want to use subdirectories to organize your work (eg for different homework sets).

cd: when followed by a directory name moves you down into that subdirectory.

cd ..: pushes you back up one level in your directory tree.

pwd: tells you the directory/subdirectory you are currently working in (pwd means `print working directory')