There are several great reasons to choose dedicated server hosting for your thriving website. In the unlikely event that you have not, sign up for dedicated server hosting with Hostific which uses trusted Linux operating systems. You will be able to choose the popular Ubuntu, but other options are available: Debian, Fedora, Gentoo, OpenSUSE, and CentOS. The latter can be paired with cPanel if you rather. It is good practice to list running processes (on Linux) from time to time. We’ll break down the most common commands to list processes on linux. Let’s get started.
Table of Contents
Easy steps to List Running Processes in Linux
Listing the processes means you identify those active procedures running on your server. But there’s lots more that you can learn from listing processes on Linux. Here are a few: the resources being used by a process; the effect of your load demands on your overall system and memory demands. First, well look at the ‘ps’ command and explain what you can learn from each process.
Use ‘ps’ command
The ps command is short for Process Statuses. It’s responsible for generating a snapshot of all running processes.
$ ps: produces a list of the processes currently running on the specific shell (or account). This information is static and limited, so you will need to expand the command to know more.
$ ps a: lists all processes on all shells of your server
$ ps u [username] OR $ ps ef | grep USERNAME: if you want to list processes on Linux for a specific user from a different shell
$ ps u: adds other useful information, such as virtual memory size (VSZ), resident set size (RSS) and process identification number (PID)
$ ps x: identifies processes that usually run in the background and were started at boot time, because they have no controlling terminal
Commands (not just ps commands) are case sensitive. Check out the following commands that are the same in make-up, but will list different processes on Linux.
$ ps ef: will produce processes that include the command that called up the process, PID, User Identification Number (UID), parent process identification number (PPID), and some information about start and run times.
$ ps eF: in addition to the information above, using a capital ‘F’ will also produce RSS, the name of the processor running the process and the overall size of the process (SZ).
Perhaps the linear format is not effective. Change the format to a tree-based one with pstree.
How to use the ‘top’ command
Top commands are ideal if your goal is to list processes on Linux to identify which ones are using up the most resources. It is this fact that adds a dynamic element to top commands because the list is adjusted according to the demands of your processes.
To list processes using top, the command is $ top.
You can choose whether to list processes according to how much CPU or memory is being used per process.
Shift + m: list according to memory use
Shift + p: list according to CPU use (default)
Ctrl + C OR q: exists top
- Running/Runnable (R): the former is currently active, but the latter is awaiting a slot so it can begin performing its process
- Sleeping (D): awaiting another process (an event) or resource to continue its process. There are two types of Interruptible Sleep (S) and Uninterruptible Sleep (D)
- Stopped (T): a paused process that is awaiting prompt to either continue (SIGCONT) or officially stop (SIGKILL)
- Zombie (Z): awaiting action from the parent process to officially complete process
$ top u [username]: lists processes for a specific user
$ top p [PID]: lists the processes for a specific PID
$ top i: will not list processes in zombie state
Listing some processes in Linux can be brought about by pressing just one key (remember these are case sensitive):
k: kills process (you will need its PID)
c: reveals the full path of a program (by default this is not the case); pressing c will return you to default if in full path view
d: changes refresh time (default refresh time is three seconds)
r: changes the priority of a process (nice values that are negative get a higher priority than positive numbers; all processes begin with a value of 0)
R: reverses the default list order (changes from descending to ascending order)
N: sorts by PID
Variations of top
A popular version of ‘top’ is htop. While top is installed by default, you will need to install htop should you wish to use it. It allows you to interact with the interface and can be personalized or manipulated to get different colors.
On the whole, it comes with the same functionality as top but uses the function keys to bring about results. First, installing it is as simple as entering a line of code in a command prompt:
sudo apt-get install htop
Now that it is installed, here are some of the actions you can carry out using function keys:
F9: kills highlighted process
F5: changes display to tree mode
F3: allows for searching for a process
“ntop” is another variation geared towards a different target audience. It shows network usage instead of process usage, so both can work in tandem. Because it is web-based, a browser is needed to access its terminal. There is some configuring that is required before it can be used successfully as well.
Today’s tutorial was an introduction to listing processes in Linux. When you use a dedicated server, you must monitor its performance to get the most of its resources. There are several ways you can do this and they depend on the information that you are trying to find out.