CDA3101 Computer Organization Spring 2002

( Handout on how to use "linprog" and some of the commands available under unix)


1. newacct (creating an account)
2. logging in
3. logging out
4. changing password (passwd)
5. printing (lpr -Pmajors or lpr -Ppclab)
6. checking status of print job (lpq -Pmajors)
7. remove job from print queue (lprm -Pmajors)
8. e-mail (pine, reading messages, composing messages)
9. editor (pico)
10. list files (ls)
11. remove files (rm)
12. rename files (mv)
13. copy file (cp)
14. examining files (more, cat)
14. make directory (mkdir)
15. remove directory (rmdir)
16. compiling a C++ program (g++)
17. putting jobs in the background (&)
18. using a source level debugger (ddd, gdb)


1. newacct (creating an account)

Note: It is required that you get a computer science account for this class.

a. Go to the Computer Science majors lab. It's room 006 in the basement
of Love Building (across from the elevator).

b. Find a Linux machine or Sun Sparc station. Most of them are on the
left side of the lab as you enter the room.

c. Type "newacct" for the login and "newacct" for the password.

d. Follow the instructions that are given to you.

e. Ask for help from the lab monitor if you have problems.

or:

a. Find a machine that is on the internet.

b. ssh to linprog.cs.fsu.edu.

c. Type "newacct" for the login and "newacct" for the password.

d. Follow the instructions that are given to you.

2. logging in

a. Type in "majors" for the username and leave the password field blank.

b. Another screen will come up. This is where you type in your login name
and password.

c. Click Start (in the lower left hand corner of the screen).

d. Click run.

e. Then type: Xwin32

f. Once again type in your login name and password.

a. Make sure the machine is connected to the internet.

b. ssh to linprog.cs.fsu.edu

c. Type in your login name and password.

3. logging out

There are three command method can log off from Unix:

a. use 'logout' command

b. use 'exit' command

c. Press the control key and the 'd' key at the same time (CTRL-D)

4. changing password (passwd)

Once you are logged on, enter ssh nu.cs.fsu.edu. That will kick off the password changing program.
Follow the on screen instructions to complete.

5. printing (lpr -Pmajors)

There is one printer you can use to print out your program (the file
containing source code) in CS Majors Lab. Its the laser printer in the majors lab

lpr -Pmajors <filename>

6. checking status of print job (lpq -Pmajors)

Use the command 'lpq -Pmajors' to check the status of Majors lab printer.

7. remove job from print queue (lprm -Pmajors)

If you send a job to the printer but then decide you don't want it to be printed on the majors lab laser printer. The command 'lprm' (no quotes) will allow you to purge the job. There are two methods of purging a job:

lprm -Pmajors <userid> lpq -Pmajors Look at all jobs in the print queue
and find the entry that you want to
purge. Get your 'job id'.

lprm -Pmajors <jobid> Specify the job id as shown. This will
cause only the job specified to be
purged.

8. e-mail (pine, reading messages, composing messages)

Use the command 'pine' to read email (a message tells you that you have received mail when you login). After typing this command, "pine" will enter you into an interactive, menu-driven mailer. After reading your mail, you can save it, reply, delete it, and a variety of other functions.
See the pine man page for full details.

9. editor (pico)

There are other editors that are more powerful, such as emacs. There are other editors that are more portable, such as vi (comes with every implementation of unix). These are control commands, where you hold down the control key and the
specified other character to cause the command to occur. The primary commands
you will likely use are listed at the bottom. More details on these commands and
other commands are accessible by typing "^G".

10. list files (ls)

This is like the "dir"command in DOS. The ls command is saying
"please list the files that are in this directory".

To list the contents of another directory, you can either "cd" to it
and type "ls", or you can simply supply the directory name as an argument.
For example: "ls /etc", would list the contents of the directory /etc.

This includes permissions, owner, group, date and time of last update . "ls -F" would place a / after directories and an * after executable files.

11. remove files (rm)

Use the command 'rm <file>' to remove the file <file>.

By default, it does not ask for conformation before wiping out exactly
what you tell it to. For example, this command would erase all files
ending in `.o', and `.out':

rm *.o *.out

But be careful, the following command would remove all files in the
current directory:

rm *

You can remove a directory that you own with the "rmdir" command. The
directory must be empty before it can be removed. Use the "ls -a" command
to make sure you have removed any hidden files.

Remember: the rm command is used to delete files. Once deleted, a file cannot
be restored by yourself.

12. rename files (mv)

Use the command 'mv <file1> <file2>' to rename <file1> as <file2>.

This command can also be used to move a file or a directory to another directory.

13. copy file (cp)

Use the command 'cp <file1> <file2>' to copy the contents of <file1> into <file2>.

14. examining files (more, cat)

The command 'more' will display a file or files one video page at a time. Use the space
bar to move on to the next page; use the return key to scroll one line at a time. There are a bunch of other useful functions built into "more", such as searching for the next occurrence of a string, and scrolling backwards. screen by screen and use command 'q' to exit The command 'cat' dumps a file to the screen, which is not helpful if the file is large. For example, the following command will create a new file called "week" that is the concatenation of the five files "mon", "tue", "wed", "thur", and "fri":

cat mon tue wed thur fri > week

Note the '>' sign. It is used to indicate that the output (stdout) will go into the file 'week'.

14. make directory (mkdir)

Use the command 'mkdir <name>' to make a new directory <name>.

15. remove directory (rmdir)

Use the command 'rmdir <name>' to remove the directory <name>.

16. compiling a C++ program (g++)

a. compilation errors

If the compiler finds any errors, they will be listed by line number of your program.
You should fix all the errors in your program. One misplaced ; or missing } or */ can set off several error messages.

b. producing executables

The '-g 'option instructs the compiler to prepare the program for use by an interactive debugging tool.
The '-o' option indicates that the next argument, in this case , <file> is the name of the executable. --create object modules for each component using this command:

g++ -g -c <file>.cpp

--create the executable as follows:

g++ -g -o <file> *.o

c. running executable

Just type the name of the executable.

17. putting jobs in the background

Perform commands in the background by ending the command with a '&'.
Issuing commands in such a manner is particularly useful for long running
jobs or ones that provide their own user interface window.

18. using a source level debugger (ddd and gdb)

ddd is a graphical user interface (GUI) to many source-level debuggers. By default on linprog, it's the GUI for the gdb debugger. It provides visual feedback and mouse input for the user to control program execution through breakpoints, to examine and traverse the function call stack, to display values of variables and data structure and to browse source files and functions.

It is an efficient way to find out where logical errors are in a C/C++ program. Compilation errors are not considered as bugs here and they should be detected and removed with the
aid of the compiler and an editor.

Use the command 'ddd <executable> &' to invoke the debugger on your program. A window of ddd will pop up. There are several commands that you can issue. Many of the
commands on the (gdb) command line can also be issued using the mouse by selecting
a portion of the source code (e.g. a variable) and clicking on an icon near the top of the
window.

a. examine values of variables

1. print -- Print the value of a selected expression.

2. display -- Display the value of a selected expression in the display window, and
updates its value every time when execution stops.

b. cont -- Continue execution from where it stopped.
c. step -- Execute one source line, stepping into a function if the source line ontains a function call.
d. next -- Execute one source line, without stepping into any function call.
e. breakpoints -- Stop program execution at the line or in the function selected. To set a breakpoint in the program place the caret at the start of the source line or on the function name and click the break botton A stop sign will appear next to the source line.

f. delete -- Remove the breakpoint on the source line selected or the breakpoint number selected.

g. show breakpoints -- Show the current breakpoints (both active and inactive).
h. tracebacks (segmentation faults) stack -- Print a backtrace of the entire stack