Show all running processes in Linux

Q. How do I see all running process in Linux?

A. Both Linux and UNIX support same command to display information about all running process.

ps command gives a snapshot of the current processes. If you want a repetitive update of this status, use top command.

Task: Use ps command

Type the following ps command to display all running process
# ps aux | less

Where,

  • -A: select all processes
  • a: select all processes on a terminal, including those of other users
  • x: select processes without controlling ttys

Task: see every process on the system

# ps -A
# ps -e

Task: See every process except those running as root

# ps -U root -u root -N

Task: See process run by user vivek

# ps -u vivek

Task: Use top command

The top program provides a dynamic real-time view of a running system. Type the top at command prompt:
# top
Output:

To quite press q for help press h.

Task: display a tree of processes

pstree shows running processes as a tree. The tree is rooted at either pid or init if pid is omitted. If a user name is specified, all process trees rooted at processes owned by that user are shown.
$ pstreeOutput:

pstree output

Task: Lookup process

Use pgrep command. pgrep looks through the currently running processes and lists the process IDs which matches the selection criteria to screen. For example display firefox process id:
$ pgrep firefox

Following command will list the process called sshd which is owned by root user.
$ pgrep -u root sshd

Say hello to htop

htop is interactive process viewer just like top, but allows to scroll the list vertically and horizontally to see all processes and their full command lines. Tasks related to processes (killing, renicing) can be done without entering their PIDs. To install htop type command:
# apt-get install htop
or
# yum install htop
Now type htop to run the command:
# htop

(click to enlarge)

See also:

Want to read Linux tips and tricks, but don't have time to check our blog everyday? Subscribe to our daily email newsletter to make sure you don't miss a single tip/tricks. Subscribe to our weekly newsletter here!

{ 21 comments… read them below or add one }

1 dom 11.26.07 at 5:15 pm

i hope you dont mind, i have borrowed your image showing PS for my assigment, i have have referenced this site and the date

Dom

2 saurabh 02.20.08 at 10:23 pm

No offense, but this is akin to posting instructions on how to walk.

3 jay 03.07.08 at 1:38 am

@saurabh – I’m glad you think this is like posting instructions on how to walk. I’m also glad that you are such a naturally gifted user that you knew this without ever having to look up how to do this. Some of us have just started using Linux and guess what it is small little tid bits like this that help.

4 anya 03.11.08 at 9:28 pm

Thanks a lot for the info. It proved really useful. Sometimes it helps when somebody tells you how to walk…

5 Maria 03.26.08 at 10:31 am

It’s fantastic to know that a great community is behind it.

Thanks

6 Jamal 05.15.08 at 6:19 pm

can someone tell me how to create a script that list all processes that are taking more than 10% of cpu time?

thanks

btw i am a noob lol

7 ddd 07.06.08 at 11:11 pm

Great! Thanks

8 akinhowtowalk 08.08.08 at 10:39 pm

@saurabh no offense, are you an Indian? If so, that explains and if not, set up your own site and don’t post anything on it loser.

Great stuff.

9 WebDesignKing 09.08.08 at 2:42 pm

Lol @ akinhowtowalk. Well said!

Great resource

10 sarmad 11.06.08 at 6:42 am

i want to know how can i run command that show me which script is currently running and by which user

11 Allimuthu 12.25.08 at 7:27 pm

Hi Everybody, I got an cleared information in this site. But I want to know that what are the process currently active in my shell. If any body know, please email me @ allimut@gmail.com

Thanks,
-Allimuthu.

12 mellow_bunny 01.14.09 at 10:29 pm

Yo thanks heaps for this info! It’s just what I needed! *favourited*

13 Greg 01.29.09 at 6:21 pm

akinhowtowalk good answer for the loser :D

14 Ken 02.08.09 at 9:25 pm

I’ve been walking the Linux path for a long time and it’s nice to see this type of command posted.

To see what is running and consuming resources you could use (exactly as it is shown):
ps -e -o pcpu,cpu,nice,state,cputime,args –sort pcpu | sed “/^ 0.0 /d”

which is nice to enter into the .bashrc in your home directory as an alias. Like this (on the last line after every other entry):
alias hog=’ps -e -o pcpu,cpu,nice,state,cputime,args –sort pcpu | sed “/^ 0.0 /d”‘

so the next time I log in I can just type hog at the command line and see all process running and consuming resources, sorted.

Ken

15 unokpasabaxaki 02.16.09 at 8:51 pm

In the path of Linux, if you want to start running without knowing how to walk, what will happen? Begginers know that they can get to the top, but step by step. Otherwise, they’ll fall. And let’s stop the metaphores xD

16 vivek 02.21.09 at 4:09 am

Hello

Any one help to find command history with date & time.

17 SleepWalker 04.01.09 at 8:16 pm

Thank you. found it very useful :)
Lol@akinhowtowalk well said :)
Regards,
ILoveTakingHelp :P

18 the mad hatter 05.18.09 at 2:49 pm

Thanks for posting this ! You’ve helped me a lot !

19 HomeHacker2 05.20.09 at 5:20 pm

thanks for that. i needed this to set something running and set-up on a linux server. but i needed to kill it first so :)thanks.

20 chinmay 05.26.09 at 5:44 am

hello akinhowtowalk

i find this site really usefull and find the stuff what i was looking for…
and saurabh’s comment was not justified…
but what was ur comment on being an indian… i really didnt understood that…and y..
that explains wat..??

21 Jo 06.24.09 at 5:55 am

Thanks for the htop info, really useful tool!!!

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Tagged as: , , , , , , , ,

Previous post: RPM database location for backup purpose

Next post: Exclude Certain Files When Creating A Tarball Using Tar Command