Professional Documents
Culture Documents
What Is A Process?: Simple Unix Commands: Information About Processes
What Is A Process?: Simple Unix Commands: Information About Processes
In the examples text shown in bold type needs to be replaced by text of your own, for example the name of the command or topic on which you are looking for help.
Everything else should be typed literally as given in the examples, using lower- and upper-case as shown. (Almost everything in Unix is in lower-case.) At the end of each command you must press the Return key.
What is a process?
Whenever you run a program on one of the Sun workstations you initiate a new process. Every process is identified by a number, known as the Process ID or pid. Every process is owned by a particular user: as a rule processes that you initiate are owned by you.
The commands described below are used for finding out what is happening on the system on which you are currently logged in -- ie the system which appears in the Unix prompt. If you are logged in on langs and want to know what is happening on psych you will have to do a "remote login" to psych, using the command:
rlogin psych
This shows that you currently have two processes: the first (tcsh) is the process which is initiated when you login to the Sun; the second (ps) is the process you initiated by giving the ps command.
The ps command will tell you if you have left yourself logged on elsewhere. For example the following listing tells you that you have a second tcsh process and a Pine process.
PID TT STAT 1772 q4 S 1892 q4 R TIME COMMAND 0:00 -tcsh (tcsh) 0:00 ps
1849 q5 S 1887 q5 S
Shutting down unwanted processes You can shut down unwanted processes using the kill command. You can do this if you have left yourself logged in somewhere else, or if your screen has frozen on one terminal and you are logged in from another. For example
kill 1849
After giving the kill command you should use ps again to make sure it has worked. If it doesn't work you can use the -9 switch -- eg
kill -9 1849
Naturally you can only use the kill command to shutdown your own processes, unless you have super user privileges.
will give a list with details of all the processes currently active on the system. Because it is likely to be a long list, you should usually use the "pipe to more" facility:
ps -af | more
You can also search for particular sorts of process using the grep command. grep searches for a given string of characters within a file. If you "pipe" the output from ps into grep it will search for a string and only display those lines on which the string occurs. For example
ps -af | grep pine
will show you all the people who are using pine on the system:
jmy 359 0.0 0.0 /usr/local/bin/pine3.96 wc2 24776 0.0 0.0 /usr/local/bin/pine3.96 cdl 1485 0.0 1.8 /usr/local/bin/pine3.96 sz 2280 0.0 0.0 /usr/local/bin/pine3.96 pcu 2737 0.0 0.7 848 836 624 692 32 0 q9 IW 0 q0 IW 540 q2 S 0 p7 IW 204 q4 S May May 18:33 18:51 19:00 2 2 0:46 0:41 0:07 0:05 0:00 grep pine
igm 1690 0.0 5.3 696 1616 p8 S 18:39 0:09 /usr/local/bin/pine3.96 Look in the man pages for ps for information on the various columns in this display.
For example, Ingres requires some additions to be made to the PATH environment variable. These are done with the setup ingres command.
to get a list of the current environment variables and their values Use the env command.
For example, use the following sequence of commands to find the value of the PATH environment variable before and after setting up Ingres:
env setup ingres env
The "env" command might give more information than can fit on a single screen, so you should use the "pipe to more" option: env | more
IT training page