While managing our server, we'll need to understand what processes are running and how to manage these processes. We first need to be able to determine what is actually running on our server. The ps command allows us to do this.
Step 1 : The ps command will show a list of processes running by the user that called the command.
Step 2 : Continuing with the ps command, there are several useful options you can give the command in order to change the way in which it shows its output. If you use the a option, you'll see more information than you normally would:
Step 3 : Let's continue on with the ps command and look at some additional options. First, let's see what we get when we add the u option to our previous example, which gives us the following example command:
Step 4 : But perhaps the most common use of the ps command is the following variation:
With the x option added, we're no longer limiting our output to processes within a TTY (either native or pseudo). The result is that we'll see a lot more processes, including system-level processes, that are not tied to a process we started ourselves.
Step 5 : In practice, though, the ps aux command is most commonly used with grep to look for a particular process or string. For example, let's say you want to see a list of all vim worker processes. To do that, you may execute a command such as the following:
Step 6 : If all we wanted to do was to show processes that have a particular string, we can also do the following:
Step 7 : Another useful variation of the ps command is to sort the output by sorting the processes using the most CPU first:
Step 8 : Unfortunately, that command shows a lot of output, and we would have to scroll back to the top in order to see the top processes. Depending on your terminal, you may not have the ability to scroll back very far (or at all), so the following command will narrow it down further:
Step 9 : I can do the same but with the most-used memory instead: