- So we have seen the top utility
and the top utility really is very common utility.
But there's another utility that's important when it comes
down to managing processes and that's ps.
Ps is what you used to find properties about your processes.
So you can use your own ps as the main command
to show running processes, but it'll only give you processes
for your current user account.
If you wanna see all processes, use ps aux.
That'll show all processes,
including the most useful information about these processes.
The A is for all the U is showing users,
the user that has started the process,
and the X is showing some additional information.
Notice that in ps aux
we don't have a hyphen in front of the aux.
And that is because ps
by default is BSD style, Linux command.
Like we have seen for the tar command earlier.
Ps fax is quite convenient as well.
It'll show you parent-child relations between processes.
And that is convenient because
if you are killing a parent process,
normally you would kill the child processes as well.
So if you wanna be careful about process management,
you better investigate having a look at ps fax
to see if there are any children available as well.
Now ps can be used with many other options
to display specific properties only and apply filtering.
Honestly, it's so many that you probably are better
off using the top utility,
because in top you can also see these properties
in a context that makes sense,
context that is based on busiest processes.
You should consider piping ps output to other tools
like awk and sort to filter and sort specific output.
And that is how you will normally use it.
You want to monitor HCTP.
You want to know if your web service
is up and running.
Now, what are you going to do?
Well, ps aux pipe, grab HCTP.
And you will see whether or not it is running,
including all of the properties that you need
for further management.
Let me demonstrate.
So to start with, let me do a ps aux pipe less,
so that we can see the header column as well.
So we have the username. We have the PID.
The PID is pretty important for managing the process.
The CPU use it, the memory use it,
VSZ and RSS is about memory usage.
TTY showing where the process is running.
If it is running on a TTY, we can see the status,
where an S is what you see most frequently
is for a sleeping process.
You see start information, you see time,
the that's the amount of time that process has been running.
And in the last column, you see the command as well.
User, PID, Command.
That's the information that you will be looking at
in most cases.
Now about ps fax.
Well, if I use ps fax,
we can see this hierarchical overview,
like what we see here.
Here we see there is this known terminal server.
The known terminal server has a child process,
which is bash,
and that one is child processes process, which is ps fax.
And it means that
if anything happens to the known terminal server,
that will have consequences for all of the child processes.
And that is why you might be interested in using ps fax.
Ps - ef, hey, suddenly we have a minus.
Yes, it is right.
Because ps has a nature as a BSD command,
but it also has system a five way of working.
And if you want to display more or less the same information
using either BSD or system five dialect,
you will see that the options are completely different.
So ps - ef is more or less compatible
to what you have seen in ps aux,
but it's a different approach.
You can also apply advanced filtering options,
like ps - e - o pid, args -- forest
which is showing PIDs and the process forest,
which is the tree like structure
that we have just seen in ps fax as well,
which allows you to display parent and child relations.
Ps has many options.
There's one more that I want to show you.
And that's ps aux -- sort pmem
What is that?
That's sorting on memory usage,
where we can see that the process that is using
the largest amount of memory is listed last.
And that can be useful to figure out
who is busiest on your system.
I think this is enough about ps.
There are so much more that you can do with ps,
but these options are not as important.
As I said before, you probably are better off using top
if you want to find advanced process properties.