UNIX is the multi-user operating system on the SUN computers. It uses a hierarchial directory system very similar to folders or directories on a PC. Thus a subdirectory to a directory is like a folder in a folder. The root directory is the slash (/). To see your current working directory, type:
condor{smithj}1: pwd (path of the working directory)
/home/condor/call2417/smithj
condor{smithj}2:
The following is a basic set of very useful UNIX commands to get you started. Note that UNIX (and C++, for that matter) is case sensitive - it distinguishes between upper and lower case characters.
ls
list the files in the current working directory.
ls -l
list the files in the current working directory in the long format.
cd directory_name
change the current directory to the directory_name. The
default (no name supplied in the command) is to return to the
user's home directory.
cp file_name target
copy a file to a new name or location. Target may be a subdirectory
or another file name. Target (.) refers to your current working directory and target
(~)
refers to your home directory. File_name (*) means copy all the
files in the current directory.
mv file_name target
moves or renames files. Target may be a subdirectory or another
file name.
rm file_name
remove the named file. It cannot be subsequently recovered so
it pays to be careful.
rm -r directory_name
remove an entire directory along with all of its files and directories.
These cannot be subsequently recovered so it pays to be careful.
mkdir directory_name
create a named directory. It will be
a subdirectory of your current working directory.
rmdir directory_name
remove empty directories from the file
structure.
cat file_name
display contents of a text file on the terminal.
cat -n file_name
display contents of a text file on the terminal as well as the
line numbers.
more file_name
display contents of a text file on the terminal one page at a
time. Press "space bar" to continue and either "q" or
"ctrl+C" to quit.
man command
show the manual page for the command.
file file_name
classifie files according to basic types. Useful to see if named
file is a text file before looking at it or attempting to print
it.
print file_name
print a text file on the line printer. (Not a standard UNIX command
- replaces lpr)
vi file_name
edits a text file. See below.
g++ file_name.cpp
-o file_name
compiles and links a C++ program.
SUN C++ source files must have names ending with .cpp (note lower case). We use the gnu C++ compiler g++. We always choose the same name for the executable file without the .cpp suffix, thus assuming that the source code of our program is named 'my_program.cpp':
condor{smithj}3: g++ my_program.cpp -o my_program
Then to execute:
condor{smithj}4: my_program