CS 241 Very Brief Unix Tutorial


Below is a list of useful Unix commands.

In order to use the SUN C++ compiler you must type "pkgaddperm sc". Then just use the "CC" command. (Note: If you want to use CC the same session when you do pkgaddperm sc, you must also type "pkgadd sc".) We strongly recommend that you use makefiles for compiling and linking your programs.

To run your program type "name.out" where name.out is the name of your executable. If you want to stop your program in the middle type "ctrl-c".

You can obtain copies of all the provided files for the labs by selecting the README entry from within the CS241 Lab page and then saving the files. Another way to get copies of the provided files is to copy them from the CS241 course account. For example if you want to copy the README file for lab 1 you would type

cp /home/cec/class/cs241/lab1/README file

where file is the name to be given to the file in your local directory. Other files can be copied in a similar manner by just replacing README with the filename.

Or if you want to save some typing, you can copy the entire lab1 directory by typing

cp -r /home/cec/class/cs241/lab1 directory-name

where directory-name is the name of the directory that will be created in your current directory in which all the files in the cs241 lab1 directory will be placed. As another example suppose you wanted to copy all of the files with the suffix "cc" from the cs241 lab1 directory into your current directory. Then you could type

cp /home/cec/class/cs241/lab1/*.cc .

In order to generate your output you can use "script file" which will save everything from your shell (until you type exit) in the given file. If you do not provide the filename for the script then the default name is typscript. If you want to append to the output file (versus overwriting it) then use "script -a file"

Another useful command is "prog.out < input > output" where "<" indicates that input is to be used for the input instead of the shell input and ">" indicates that the output should go to output instead of the shell. Note that you can specify just the input or output file if desired.


Here is a summary of other UNIX commands you may need:


Return to the
CS241 Home Page