Ooooh... homework help aye?
Listen: you have to do your own homework.
However: I can help you understand your homework questions and put you on the right track OK? (And shame on anyone who just supplies the method...)
in terminal, "man ps", will tell you all about what ps does and is, and supplies example of how to use it. English language will be a problem for you here - but care will help you: this is one of the simpler man pages.
$ ps
will display a list of running processes to stdout (the terminal). For eg. On my system I get
Code:
[~]$ ps
PID TTY TIME CMD
4179 pts/1 00:00:00 bash
4827 pts/1 00:00:00 ps
You can get a record in a text file by typing
$ ps > foo.txt
... and you'll fine a file called "foo.txt" with the same stuff in it in whatever directory you were in when you typed the line. Of course, it is useful to choose a discriptive file name... like "ps.out" suggested by the teacher.
ps can be run with various options to alter the output.
for eg: $ps -f gives you the "full" description of the processes. Again, for me, this is:
Code:
[~]$ ps -f
UID PID PPID C STIME TTY TIME CMD
simon 4179 5619 0 20:01 pts/1 00:00:00 bash
simon 4859 4179 0 21:11 pts/1 00:00:00 ps -f
See the difference?
the -e flag gives you "everything"... a list of all processes running on the machine. This can be rather long so I'll not give you an example.
$ps -e -f
is the same as
$ps -ef
and gives you a full list of all the processes.
This should be enough to start you off.
What you need in written in the man page for ps.
Good luck.