Linux Command to List Currently Running Processes (Part 5/15)

Linux command to list currently running processes

One file is everything in Linux. When a file is executed, it is understood as a process. The process is created by another process and is destroyed after being used. Various processes can be run on the Linux system and various commands are specified for process management. Each process is identified by a unique number called Process-ID (PIDwhich is allocated while the process is created. From the parentPID. If you run any single command from the terminal shell, it will also create a process. Refer to the Process in Linux tutorial for get more information about the process.

Here I will explain various process commands that provide information about the running process.

Ps command (process status)

The ps command displays the same process attributes owned by the user running the command.

Open the command terminal by typing the following command and pressing the Enter key:

note:

The following output is displayed on the screen:

PID TTY TIME CMD

2637 points/1 00:00:00 party

5505 points/1 00:00:00 ps

Each line displays information such as process ID (PID), terminal the process is associated with (TTY), processor time (TIME), and process name (CMD).

here the first line (expecting the header line) is the login shell process information and another line is the ps command process information.

Complete listing of the current running process

The complete list of the current running process includes information from each process's parent and user.

Command: ps <-f>

Option f indicates the complete listing

Type in the command terminal:

ps-f

The following output is displayed on the screen:

UID PID PPID C STIME TTY TIME CMD

Ashish 2637 2629 0 06:16 points/1 00:00:00 party

ash 5647 2637 0 10:53 points/1 00:00:00 ps –f

List of all current running and system processes

The list of all currently running processes includes user and system processes.

Command: ps <-e>

The -e option indicates all processes, including user and system processes.

Type in the command terminal:

ps-e

The following output is displayed on the screen:

PID TTY TIME CMD

1? 00:00:03 start

two? 00:00:00 kthreadd

3? 00:00:01 ksoftirqd/0

5608? 00:00:00 worker/u16:0

5664? 00:00:00 worker/u16:2

5668 points/1 00:00:00 ps

Note: Process information changes on different systems depending on the Linux distributor.

The process belongs to a specific user

The system administrator can obtain user activity using the ps command. The ps command provides the list of processes associated with a specific user.

Command: ps <-u>

The -u option displays the process for a specific user.

Type in the command terminal:

ps -you gray

Note: here ashish is the system username

The following output is displayed on the screen:

PID TTY TIME CMD

1816? 00:00:00 keyring-gnome-d

1852? 00:00:00 start

1952? 00:00:00 dbus daemon

1963? 00:00:00 start event-b

1975? 00:00:00 window-stack-br

List process based on PID or PPID

Sometimes we want to know about the child process associated with the specific parent process where they were born. The –ppid option used for specific parent ID child process information and the –pid option provides complete specific child process information.

Command: ps <–ppid or –pid>

Type in the command terminal:

ps –ppid 1

Note: Here 1 is the main system process, which is the parent of several child processes.

The following output is displayed on the screen:

PID TTY TIME CMD

264? 00:00:00 newbie-udev-br

271? 00:00:00 systemd-udevd

403? 00:00:00 dbus daemon

446? 00:00:00 systemd login

457? 00:00:00 rsyslogd

459? 00:00:00 bluetooth

531? 00:00:01 avahi-daemon

634? 00:00:00 ModemManager

663? 00:00:00 file-upstart-br

Now enter the command to get child process specific information in full format:

ps -f –pid 634

The following output is displayed on the screen:

UID PID PPID C STIME TTY TIME CMD

root 634 1 0 09:47 ? 00:00:00 /usr/sbin/ModemManager

Process tree structure

The processes are associated with each other in a hierarchical manner. Each process can be the parent of the child process or the child process of the parent process. System administrator can get process tree based on PID.

Command: pstree Process PID>

Type in the command terminal:

ps –ppid 1

Note: Here 1 is the main system process, which is the parent of several child processes.

The following output is displayed on the screen:

init─┬─ModemManager───2*({ModemManager})

├─NetworkManager─┬─dhclient

│ ├─dnsmasq

│ └─3*({Network Manager})

├─account daemon───2*({account daemon})

├─acquit

├─avahi-daemon───avahi-daemon

├─bluetoothd

├─colord───2*({colord})

├─cron

├─cups-navigated

├─cup

├─cupsd───dbus

Note: Process information changes on different systems depending on the Linux distributor.

Related Content

Back to blog

Leave a comment

Please note, comments need to be approved before they are published.