Using UNIX and C++

NOTATION

What you are to type at the terminal will be given in bold face, computer response in italics.

^x denotes holding down the control key and typing x.

LOGIN PROCEDURE (you must have a user name and password which will be given out in class) First you must connect to our system. The full name for our computer is phobos.ramapo.edu.

If you are working at school, double click on the phobos or ssh client icon.

If you are working from home and have an Internet connection use telnet to get access to the our computer. Click on the start button, then the run button. Then type     telnet phobos.ramapo.edu.  Or, better still, download SSH Secure Client from CCIS.

In either case, you should get as response that ends with the following:

 
SunOS 5.9

login:


You will then type your user name, which will be given to you in class. Next you will be prompted for your password. You will then enter your password.  This is for the sake of security you have been given a nasty password. The password must be 6 to 16 characters in length. For future changes of your password, type passwd and then follow the prompts to change the password.   Note: some companies configure their UNIX systems to force you to periodically change your password.

UNIX COMMANDS: The following is a list of some of the more important UNIX commands categorized by use:  Note that I have not given all the options to the commands.  Further note that the people who developed UNIX do not like to type.  So the commands are pretty abreviated. USING THE ON-LINE MANUAL UNIX provides an on-line manual of its commands. To get a detailed description of any command type man followed by the name of the command. If you don't know the name of the command, type man -k followed by a key word that describes the command you are looking for. The man command will then list all the commands whose description contains the key word.  This can be a lot of commands.  Note: most commands have a LOT of options.  Also, we will talk about additional commands as the semester progresses. FILES AND DIRECTORIES ls
List the files in the working (also referred to as current) directory

ls -l
Long listing of the files in the working directory.

ls pathname
List all the files in the specified directory.

more pathname
List the contents of the specified file.   Mention less

tail pathname
List the contents of the end of a specified file.  Defaults to listing 10 lines.  Good for looking at log files.

cp f1 f2
Copy the contents of file f1 into file f2.

mv f1 f2
Rename f1 to be f2.
  

rm f1
Removes the file f1.

cd dirname
Changes the working directory to dirname.

cd ..
Makes the parent directory, the working directory.

cd
Makes your home directory the working directory.

rmdir dirname
Removes the directory dirname The directory must be empty.

mkdir dirname Creates the directory dirname.

rm -r dirname
Removes the directory dirname and all the files contained within it. This is a dangerous command.  It also comes in handy at times.
   NOTE: UNIX assumes you know what you are doing.  There is no "are you sure" prompt.

pwd Displays the working directory.

MISCELLANEOUS COMMANDS ^c Terminates the execution of the current command or program.

^d or "logout" or "exit" Logs you off the system. To protect yourself, don't forget to log off.

^z stop the running program, but do not terminate it.  The fg (foreground) command will restart it.

SPECIAL SYMBOLS ~ Equivalent to typing your home directory.

* Matches any string of characters.

? Matches any single characters.

EXAMPLE: ls *duck* will list all the files names that have the word "duck" appearing anywhere in them.

MAKE FILES UNIX provides the make command. This command requires a file named "makefile" or "Makefile". This file lists the dependencies between the various elements that make up your program and actions to be taken. The make utility will use this file to create an executable program. The following is a example of the contents of a make file used to create an executable program for the C++ file "lab1.cpp".   The C++ associated with Solaris is named "CC" and the gnu C++ compiler is named "g++".  Unless it has shortcomings, we will use gnu for the C++ compiler.lab1: lab1.o
<tab> g++  -g lab1.o -o lab1

lab1.o: lab1.cpp
<tab> g++  -g -c lab1.cpp          note: don't forget to have a CR after the last statement.  Otherwise it is ignored on many UNIX systems.

Additional Commands

As the semester continues I will introduce some fancier commands.