How to Use the ps Command to Find Running Processes on Linux

Chưa phân loại
The full form of ps is process status. It is a command used to find information about currently running processes on Linux. ps is a very important command of Linux.In this article, I will show you how to use the ps command to find running processes on Linux. So, let’s get started.

Different Types of Options:

The ps command accepts different options.

  1. UNIX options – have leading dash.
    $ ps -e
  1. BSD options – don’t have leading dash.
    $ ps aux
  1. GNU options – have double leading dash.
    $ ps –pid 1001

In this example, I will use the UNIX and at times GNU options. But the BSD options are similar. Most of the time, you can mix them together without any problems. Although, you can’t mix some of the options together as it won’t work. So, be careful.

Finding All Running Processes:

With ps command, you can find all the running processes on your machine.

To find all the running processes with ps, use ps as follows,

$ ps -ef

As you can see, the UID (User ID), PID (process ID), PPID (parent process ID), CMD (command used to run the process) and some other information about all the running processes are displayed.

You can list all the running processes with different ps options combination. They will show different information about the running processes. You can actually tell ps to display specific information, which we will get to in the later section.

$ ps -e

As you can see, ps -e shows the PID, TTY (terminal number), TIME (process running time) and CMD of the running processes. That’s a lot less information than earlier.

$ps -ef

It shows a lot of information about the running processes, but some of the columns such as C (processor utilization), SZ (size in physical pages), RSS (resident set size), PSR (processor that process is currently assigned to), STIME (the time when the process started) etc. are not displayed. So, it’s a little bit more compact than ps -eF.

Another variant of ps,

$ ps -ely

This one shows you UID (user ID), PRI (current priority of the process), NI (nice value) as well. So, it’s really handy.

Making ps Navigation Easy:

A typical Linux system has a lot of process running in the background. So, the output of the ps command is very long. It is harder to find useful information there. But, we can use a pager such as less to look for the processes a little bit easier.

You can use the less pager as follows:

$ ps -ef | less

The output of ps will be opened with less.

Now, you can use <Up> and <Down> arrow keys to navigate the list very easily.

You can also search for specific keywords here. This is really helpful for finding the processes that you’re looking for.

To search for a processes, let’s say acpi, type in the keyword as follows in the less pager.


Now, press <Enter>.

As you can see, the process with the keyword acpi is highlighted.

You can also press n and p keys to go to the next and previous match (if available) respectively.

As you can see, I pressed n to and the next process with the keyword acpi is highlighted.

To exit out of the pager, press q.

Manually Select Columns to Display in ps:

The ps -e / ps -ef / ps -eF etc command shows some default columns. But, if you want, you can tell ps to show you specific columns, or add additional columns to the default set of columns.

For example, let’s say, you want to see only %MEM (percent memory usage), PID (process ID) and UID (process owner ID) and COMMAND (process command), then run ps as follows:

$ ps -e -o %mem,pid,uid,comm

As you can see, ps displayed only the information that I asked it for. Nothing more, nothing less.

The column keywors used here are %mem (for %MEM), pid (for PID), uid (for UID), comm (for COMMAND). ps supports a lot of keywords. You can find the whole list in the man page of ps.

Just open the man page of ps with the following command and navigate to the STANDARD FORMAT SPECIFIERS section as shown in the screenshot below.

$ man ps

If you want to display additional columns along with the default set of columns, then you can use the -O option to specify the columns that you want to see.

For example,

$ ps -ef -O %cpu

As you can see, I added %CPU and %MEM column along with the default columns of ps -ef command.

Sorting Output of ps Command:

You can also sort the output of ps according to any specific column or columns. You can sort the output of ps in the ascending or descending order depending on your requirement.

To sort the output of ps using any single column, you can use ps as follows:

$ ps -ef –sort=(+|)column_code

Some example will make it clearer.

Let’s say, you want to sort the processes depending on how long the process is running in ascending order. You can run ps as follows:

$ ps -ef –sort=+time


$ ps -ef –sort=time

NOTE: The default is sorting in ascending order. So you can omit the + sign if you want.

As you can see, the output is sorted in the ascending order by the TIME column.

Again, let’s say, you want to sort the processes depending on how long the process is running in the descending order. Then, the ps command would be:

$ ps -ef –sort=-time

As you can see, the processes that are running for the longest is listed first.

If you want to sort by multiple columns, just add the columns as follows:

$ ps -ef –sort=time,-%mem,%cpu

Where to Go Next?

I’ve covered the basics of the ps command. Now, you should be able to learn more about the ps command from the man page of ps.

You can access the man page of ps as follows,

$ man ps

For example, you can find specific process if you know it’s PID using ps as follows:

$ ps -O %mem,%cpu -p 2060

NOTE: Here, 2060 is the PID of the process.

You can also search for processes owned by specific user or group etc as well.

For example, to find all the running processes of your login user, run ps as follows:

$ ps -O user,%mem,%cpu -U $(whoami)

NOTE: You can replace $(whoami) with any username you want to list processes running as that user.

So, that’s how you use ps command to find running processes on Linux. Thanks for reading this article.

Sandclock IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, Sandclock IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Install Zorin OS Lite

Zorin OS is one of the most polished Linux distros out there. It’s geared more towards new Linux users. It’s an interesting...

How to Install and Play Doom on Linux

Introduction to Doom The Doom Series originated in the 90s after the release of the original Doom. It was an instant hit...

Create Animated Presentations with AnimationMaker

AnimationMaker recently discovered, is an amazing app that allows you to create animated presentations. You can build a...
Bài Viết

Bài Viết Mới Cập Nhật

Hướng dẫn chuyển đổi windows server windows evaluation to standard và active windows server 2008 + 2012 + 2016 + 2019

How to Update Ubuntu Linux

Squid Proxy Manager cài đặt và quản lý Proxy Squid tự động trên ubuntu

Hướng dẫn cài đặt Apache CloudStack

Hướng dẫn ký file PDF bằng chữ ký số (chữ ký điện tử) và sửa lỗi mới nhất 2021 foxit reader