LAB2 PROCESS CONTROL
UNIX/LINUX TRAINING MANUAL ( TOO GOOD TO
IGNORE !!!!!)
PROCESS MANAGEMENT
When working in a shell
environment, multiple jobs can be started. Each program executed is a
job. if you run Netscape then Netscape is a job. Every job whether user
invoked or by the system has an associated job number and an id. The
jobs the user invokes have a user id or UID. Jobs that are run by
the system have root UID. Follow the instruction below to understand how
to manage your jobs. There will come a time when you will want to
terminate a job and it will be necessary to understand how to do it
without any problems.
- The top
command
PID
|
USER
|
PRI
|
NI
|
SIZE
|
RSS
|
SHARE
|
STAT
|
LIB
|
%CPU
|
%MEM
|
TIME
|
COMMAND
|
907
|
root
|
18
|
0
|
1052
|
1052
|
94290
|
R
|
0
|
.2
|
.90
|
0:00
|
top
|
1
|
root
|
0
|
0
|
420
|
420
|
3422
|
S
|
0
|
99
|
3.2
|
11:00
|
init
|
2
|
root
|
0
|
0
|
0
|
0
|
233
|
SW
|
0
|
.9
|
2.2
|
2:20
|
kflushd
|
- press the Ctrl C key to get out
of top
- type matlab <enter>
- go to another shell and invoke top
- locate matlab on the right column and its corresponding PID
number
- copy or remember the number and get out of top ( Press
the Ctrl key and the letter "C" key at the same time....)
- type kill followed by the PID number e.g. kill 10188
<enter>
- matlab should have been killed
- ps command
- type ps
- the ps command alone will
show you what shell you are running i.e. bash shell
- type tcsh
- Now you have switched over to Tomcshell. This type of shell
is really popular in dec-alpha and sgi machines. Linux prefers the bash
shell because it is more powerful. In this course we will be confining
ourselves to the bash shell
- to get out the tcsh shell
- You should be back in the bash shell environment. To check,
type ps again
- Now do the following in the shell
- this is another way of checking your jobs or system jobs
- Background(bg) and Foreground(fg) jobs
A background job is invoked by
appending the & symbol after a command; a foreground job is taking
a background job and putting it in the forground whereby the shell is
occupied. When you invoke a job or action in a shell e.g top, the shell
cannot accept any other commands from you: the shell is occupied. When
a background job is initiated the job runs in the background thus
allowing you to continue work on the shell. When you do not see the
command prompt ($) re-appear after a command then you should be aware
that the shell is occupied and no other jobs will be accepted until
this job terminates.
- type the following commands
- nedit &
- you have just created a background job for the nedit editor. The command prompt re-appears and is good to go !
- jobs
- jobs will list the programs running specific to this shell.
Its like a local variable i.e. other shells will not know about it. The
job number is the number within the square brackets e.g. [1]
- kill %job number
- nedit &
- fg
- the job moves to the foreground and uses the shell
- Ctrl ^c (press the Ctrl key and the leter c key at the same
time. The ^ symbol is a control sequence specifier)
- Now type
- this will put the job in the background
- Mounting a floppy or cd (optional)
- The floppy
- insert the floppy into the bay
- type mount /mnt/floppy <enter>
- type cp /mnt/floppy/* .
- The above command copies all the files in the floppy into
the dir from where you have issued the command.
- * is a wild card symbol it tells the shell that
verything is game for copy. ~/ is your home dir ..... remember ??
- . the period tells the shell that you want to copy the
contents of floppy from some dir into that dir !
- go into floppy byh typing cd /mnt/floppy
- type ls to view the contenst fo the floppy
- type cp or mv * ~/aeror361/lab2
- insert the cd
- type mount /mnt/cdrom
- copy and move like you have been doing. You can write into
this cd since its a read write cdrw
- Standard Input and Standard output
- There may be times when you copy the contenst of a man page to
a file. The output to the terminal from the density program may also be
needed to be copied to a file or you may want to read in your altithude
from a file without open statement in your code. For such occasions we
use the standard output symbol ">" and the standard input symbol
"<" .
- type the following commands
- type man ls > man.dat
- type ls
- there should be a file man.dat in that dir
- type cat man.dat
- this will show you the contents of the file non stop
- type less man.dat
- this will show you the contents of the file with user
having control over the scroll speed
- use the up and down arrows and the enter key to scroll
- the same with more, but with a minor difference. I leave
that to you.
- in the exe/ dir of your density code create a file called
input.dat
- insert your altitude in input.dat and save-exit the file
- type ./code.x < input.dat
- the code should run the same way as before
ADVANCED FILE AND DIRECTORY MANAGEMENT
- copy a dir and its contents
- cp -r aero361 aero361_dummy
- -r option is the recursive flag that tells the command to copy
the dir and everything in it
- man cp
- check out other neat options, specially the -i option
- rm a dir and its contents
- rm -rf aero361_dummy
- the -rf option removes recursively and overides the -i
option
- man rm
- check out other neat options
Using the man page : Problem Statement (20 pts) (USE
gnumeric SPREAD SHEET)
- Practice using [Unix
help:Required Commands] and their options by using the "man"
command.
- Determine options which you would expect to be of most use to you
(no more than 4 required for each command) for each of the commands
marked with *.
- Refer to the
- Use the oocalc spread sheet program on the linux workstation. To
invoke oocalc- type oocalc after the prompt.
- Submit the spread sheet the following week when you have lab
- Make sure it is done in a neat and tidy fashion.
- Organization is vergy important.
- The usage of the man page is crucial !
- do a man of ifc instead of f77
- type q to get out of man page
- type in shell
- gnumeric
Submit:
A table prepared using "xess" in the following form:
| Command |
Options |
Description |
| ls |
|
list the contents of a directory |
| |
a |
list all files ( includes
.files ) |
| |
d |
.
|
| |
F |
.
|
| |
l |
.
|
SYMBOLS LEARNT THUS FAR
These symbols have more than one meaning, but in the context of todays
lab they represent the following
- ~
- *
- wild card that selects all strings
- > and <
- standard input and standard output
- &
- .
- @
- ^
- %