How to View All Running Processes in Linux

How to View All Running Processes in Linux

You can use the ps command. It can display relevant information about the currently running process, including the process's PID. Both Linux and UNIX support the ps command, which displays information about all running processes.

The ps command provides a snapshot of the current process. If you want the status to refresh automatically, you can use the top command.

ps Command

Enter the following ps command to display all running processes:

# ps aux | less

in,

-A: Display all processes

a: Display all processes in the terminal including those of other users

x: Display processes without a controlling terminal

Task: View every process in the system.

# ps -A
# ps -e

Task: View processes running as non-root

# ps -U root -u root -N

Task: View the processes run by user vivek

ps -u vivek

Task: top command

The top command provides a dynamic real-time view of a running system. Type top in the command prompt:

# top

Output:

Press q to exit, press h to enter help.

Task: Display a tree view of the process.

pstree displays the running processes in a tree format. The root node of the tree is pid or init. If a username is specified, the process tree will be rooted at processes owned by that user.

$ pstree

Sample output:


Task: Use ps to print the process tree

# ps -ejH
# ps axjf

Task: Get thread information

Enter the following command:

# ps -eLf
# ps axms

Mission: Get security information

Enter the following command:

# ps -eo euser,ruser,suser,fuser,f,comm,label
# ps axZ
# ps -eM

Task: Save process snapshot to file

Enter the following command:

# top -b -n1 > /tmp/process.log

You can also email the results to yourself:

# top -b -n1 | mail -s 'Process snapshot' [email protected]

Use the pgrep command. pgrep can find currently running processes and list the process IDs that meet the conditions. For example, to display the process ID of Firefox:

Task: Find Process

$ pgrep firefox

The following command will display the process named sshd and owned by root.

$ pgrep -u root sshd

Say hello to htop and atop

htop is an interactive process viewer similar to top, but with vertical and horizontal scrolling to view all processes and their command lines. Process related operations (killing, renicing) do not require input of PID. To install htop enter command:

# apt-get install htop

or

# yum install htop

Type htop in the command prompt:

# htop

atop tool

atop is an interactive monitoring tool for viewing Linux system load. It shows the usage of key hardware resources (from a performance perspective) at the system level, such as CPU, memory, disk, and network.

It can also show which processes are causing a certain load based on CPU and memory load at the process level; and can show disk and network load per process if the kernel patch has been installed. Enter the following command to start atop:

This is the end of this article about how to view all running processes in Linux. For more information about viewing running processes in Linux, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • 4 ways to view processes in LINUX (summary)
  • Linux method example to view all information of the process
  • How to view process stack information in Linux
  • How to view the processes that currently occupy the most CPU or memory in Linux
  • How to view ports, processes and kill processes in Linux
  • How to view the number of file handles opened by a process and how to modify them in Linux
  • How to view the number of handles occupied by system processes under Linux
  • In-depth understanding of viewing process memory usage under Linux
  • Check which processes occupy the swap partition in Linux to implement a script
  • How to check which program/process occupies a port in Linux/window
  • How to view the process number and program name of the port occupied in Linux

<<:  JavaScript functional programming basics

>>:  MySQL's method of dealing with duplicate data (preventing and deleting)

Recommend

What are the image file formats and how to choose

1. Which three formats? They are: gif, jpg, and pn...

Functions in TypeScript

Table of contents 1. Function definition 1.1 Func...

MAC+PyCharm+Flask+Vue.js build system

Table of contents Configure node.js+nvm+npm npm s...

CSS method of controlling element height from bottom to top and from top to bottom

Let’s start the discussion from a common question...

Detailed explanation of MySQL execution plan

The EXPLAIN statement provides information about ...

CSS menu button animation

To write a drop-down menu, click the button. The ...

Detailed tutorial for installing mysql5.7.21 under Windows

This article shares the installation tutorial of ...

Detailed example of clearing tablespace fragmentation in MySQL

Detailed example of clearing tablespace fragmenta...

Html tips to make your code semantic

Html semantics seems to be a commonplace issue. G...

Configure VIM as a C++ development editor in Ubuntu

1. Copy the configuration file to the user enviro...

How to track users with JS

Table of contents 1. Synchronous AJAX 2. Asynchro...

Solve the problem that Mysql5.7.17 fails to install and start under Windows

Install MySQL for the first time on your machine....

Perfect solution to Google Chrome autofill problem

In Google Chrome, after successful login, Google ...