|This manual is designed to familiarizes
users with some of the commonly used UNIX commands. Please follow all the
instructions. The first thing we need to do is to work on a machine that
has UNIX as its operating systems. If you are already on a UNIX machine
skip step (0) otherwise go to step (1).
Step (0) : Getting into a UNIX machine from a PC :
User is using a PC with Windows operating system to connect to a UNIX machine through Telnet. To establish the connection, use the Telnet manual first to make the connection, then go to the next step.
Step (1) : Logging into the machine:
We need a Login Id and a Password on the department UNIX machine. These two are unique to each individual. You are given one by the system administrator.
Login : your ID (Press Enter) Password: your password (Press Enter)
You will get the command prompt : cs.appsate.edu or
a % or a $
|1-14) To rename file1 to
history type : % mv file1 history
1-15) To make a copy of file history type : % cp history history_org
1-16) To see the contents of the file history type : % more history
1-17) To delete file3 type : % rm file3
1-18) To delete directory dir2 type : % rmdir dir2
1-19) To see the contents of a directory with all details type : % ls -la
1-20) To copy file test.C from my directory type : % cp ~rt/unixfiles/test.C .
1-21) To copy file test2.C, type : % cp ~rt/unixfiles/test2.C . (. is required)
1-22) To copy file input from that directory type: % cp ~rt/unixfiles/input .
1-23) Type % ls to list the contents of the directory.
Step (2) : Compiling and Running a C++ program
This test.C file is a simple program written in C++. Let's see if we can compile and run it. Notice that the C++ files has ".C" extension.
2-1) To compile the test.C type: % g++ test.C (it creates a.out)
2-2) To run the code type: % a.out
Let's try to read an input file and create an output file:
2-3) To compile the test2.C program type: % g++ test2.C
2-4) To run the program with input/output type: % a.out < input > output
Note that the input file already exists but the output file will be created.
2-5) To see the contents of the output file type: % more output
2-6) To print the file type: % lp output
Step (3) : Script (save all the actions in a file)
Sometimes, you want to have a file that contains your program, your input, and your output. In other words, a file that contains all the activities you have had to get your program to the end point. Script is a powerful tool provided by UNIX operating system for this purpose.
3-1) To start the script type : % script
3-2) To view your program in the script type: % more test2.C
3-3) To compile the program type: % g++ test2.C
3-4) To run the program type : % a.out < input > output
3-5) To view the output file type : % more output
3-6) To stop the script press Cntrl and D at the same time.
You just created the file typescript that contains 3-2 to 3-6.
3-7) Type ls to make sure that script file (typescript) exists
3-8) To mail the file to yourself type: % mail YourID < typescript