Show All Running Processes in Linux

Posted on in Categories , , , , , last updated January 12, 2017

How do I see all running process in Linux operating systems using command line or GUI options?

You need to use the ps command. It provide information about the currently running processes, including their process identification numbers (PIDs). Both Linux and UNIX support the ps command to display information about all running process. The ps command gives a snapshot of the current processes. If you want a repetitive update of this status, use top, atop, and/or htop command as described below.

Apart from ps command, you can also use the following commands to display info about processes on Linux:

  1. top command : Display and update sorted information about processes.
  2. atop : Advanced System & Process Monitor.
  3. htop : Interactive process viewer.

The ps command

Type the following ps command to display all running process:
# ps -aux | less
OR
# ps aux | less
Where,

  • A : Select all processes
  • u : 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: top command

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

Fig.01: top command: Display Linux Tasks
Fig.01: top command: Display Linux Tasks

To quit 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.
$ pstree
Sample outputs:

Fig.02: pstree - Display a tree of processes
Fig.02: pstree - Display a tree of processes

Task: Print a process tree using ps

# ps -ejH
# ps axjf

Task: Get info about threads

Type the following command:
# ps -eLf
# ps axms

Task: Get security info

Type the following command:
# ps -eo euser,ruser,suser,fuser,f,comm,label
# ps axZ
# ps -eM

Task: Save Process Snapshot to a file

Type the following command:
# top -b -n1 > /tmp/process.log
Or you can email result to yourself:
# top -b -n1 | mail -s 'Process snapshot' [email protected]

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
Sample outputs:

3356

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

Say hello to htop and atop

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 the htop command at the shell prompt:
# htop
Sample outputs:

Fig.03: htop - Interactive Linux / UNIX process viewer
Fig.03: htop - Interactive Linux / UNIX process viewer (click to enlarge)

atop program

The program atop is an interactive monitor to view the load on a Linux system. It shows the occupation of the most critical hardware resources (from a performance point of view) on system level, i.e. cpu, memory, disk and network. It also shows which processes are responsible for the indicated load with respect to cpu- and memory load on process level; disk- and network load is only shown per process if a kernel patch has been installed. Type the following command to start atop:
# atop
Sample outputs:

Fig.04: atop command in action
Fig.04: atop command in action
See also:

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

137 comment

    1. been tinkering with linux for 2 years, still have to reference some basic commands. If I had a penny for how many times I’ve gone something along the lines of “urh, how do I merge folders with cp again” *google, spots cyberciti* , they’ll probably have some good examples..

    1. You are a an elitest jerk. Interesting that for someone who believes he already knows everything, you are entirely ignorant of this fact. It is likely that no one was impressed by your comment except yourself.

  1. @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.

        1. amazing how something like a simple request for a bit of help on a topic can lead to racist banter….

          keep it simple, keep it clean, don’t be judgmental of Indians or any other race, and STAY ON the TOPIC of the THREAD!!

          // and yes, everyone needs to learn how to walk, and how to do the basics, before they can move to more advanced things…..

  2. 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

  3. 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

    1. $ HISTTIMEFORMAT=”%d/%m/%y %T ”
      OR
      $ echo ‘export HISTTIMEFORMAT=”%d/%m/%y %T “‘ >> ~/.bash_profile
      Where,
      %d – Day
      %m – Month
      %y – Year
      %T – Time
      To see history type
      $ history

  4. 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..??

    1. Will this do?

      1. Stand up with feet together.
      2. Put one foot forward of the other foot.
      3. Put other foot in front of the one you just moved.
      Repeat #s 2 and 3 until you have reached your destination.

  5. I’m amazed that more then one and a half year after a person has posted a single message,
    Chongopants 09.24.09 at 7:17 pm
    saurabh, stfu..
    that is all you may go on with your sad life.
    something like this is still said

  6. @akinhowtowalk – I am really offended by your remarks on a specific nation. I dont expects mature guys to make such kind of remark. really very disappointing (i can also go dirty in reaction but i dont prefer to). Make sure you comment on individual and not on any group/society/nation.

    @Saurabh – If you are an expert then i will appreciate you posting advance topics on linux and punlish the URL on this forum. If you cant do that much for community then you dont have any rights to comments on someones contribution.

  7. i probably think saurab never came back to this page after he commented on it. You guys were so foolish enough to comment back . lol
    I was just looking for something that can give me the green signal so that i can quit all running processes before i shut my computer…. And i ended up here. Looks i i still cant get what i should type to see only those processes that are running currently. Some thing like the task manager in windows . Any help with that ?

  8. Hi
    I wanted to display only PID and Process name in MAC OS. “ps” doesn’t display process name rather command only. Can Anyone help.
    Thanx & regards in advance
    Noufal

    1. As this is a commercial program I wont be installing it to have a look. I would suggest asking the question in a forum more related / dedicated to this product. Also have a look to find where the package was installed and read the manual that was supplied.
      If this manual doesn’t even cover the simple processes I would be a little worried about it considering the subject matter involved.

  9. hi,

    i’m running one process in linux server with the common user that is using by 20 people from different windows machine, i want to know who executed the command at what time in the linux server? is there any file/log location that having all the commands that executed in the server.

    Thanks in adv,
    Kebiraj

  10. Thanks a lot for this articles. I searched for one solution and found several in one page. God bless u Vivek for making some of us who are new and started to “walk” with Linux, and for those unjustified comments..well just ignored them.

  11. Great article. Thank you very much. And one thing to remember for all linuxholics, “Linux is for human being’s goodness” , sharing is the fuel that runs the community. Share everything even if you think it is less important, because there are many people who are looking for a point to startup. Knowing Linux means nothing if you don’t know the great philosophy behind it.
    thanks,

  12. Great work, very clear instruction. I’ve been using Linux for 2 years and still believe there’s a lot for me to learn or I should say to know. Pages like this makes a huge difference for learners who try and never give up. I really appreciate the time and efforts of the author, keep it up my friend. As for the guy with “walk” comment I’d like to say you don’t have to read what you don’t like, at least give this guy the credit for the time and effort for putting this together for the world and, go ahead and show the world what you’re ca[able of.

    Fred

  13. Can any one tell me how can i list all the processes launched from a directory and sort them to find the process which is consuming more memory than others.
    We are using AIX.
    Please help me.

  14. i have run vacum but still the problem not yet solved

    [[email protected] mysql]# /etc/init.d/opennms start
    Starting OpenNMS: org.postgresql.util.PSQLException: FATAL: database is not accepting commands to avoid wraparound data loss in database “postgres”
    OpenNMS runs better if you start up the database first.
    [FAILED]

  15. Great article thanks to author for this nice help.
    To all those above blaming Indian in any mean, just google our statistics over technology, you will see that you people are learning from Indian.So dont angry me again

    1. Lots of racism in America (and elsewhere), sadly. Chump still getting almost half the poll; his ratings have dipped a little after a series of spectacular gaffes and public GOP infighting, but that probably mostly just reflects the natural reticence of some voters to tell opinion pollsters to their face that they’re a racist, and not an actual opinion shift. (In the UK such opinion polling reticence at the clipboard-face produced the “shy Tory” and “shy Brexiteer” phenomena in 1992 and 2016, which badly overestimated Labour and Remain support respectively, and predicted the opposite results to actual). Rednecks seem to prevail in America, and in my estimation a Chump presidency remains a very real risk.

      The Indian space programme is well-resourced and impressively ambitious. By way of contrast, the British space programme is run on a shoestring from a garden shed in Leicester. Its crowning achievement was the BEAGLE2, which was made from old Sqezy washing-up liquid bottles and sticky-backed plastic. BEAGLE2’s signal lasted for about 20 seconds before fading away with a whimper, leading Prof. Colin Pillinger to lament: “If only Britain had applied to India for overseas aid, we could have afforded a second reel of sticky-backed plastic to hold the undercarriage together and BEAGLE2 would still be transmitting”.

  16. To show all active services, both upstart and chkconfig, try:

    ( chkconfig –list | grep :on | sed ‘s/ .*//’ ; initctl list | grep process | sed ‘s/ .*//’ ) | sort

  17. Dear Friends,

    How to check that specific process is working fine or not for eg. HeartBeat manager, IKEN process, FSM, LSTP etc etc.

    kindly suggest

    Regards
    Chaitanya Mahamana
    9871351236

  18. I’m glad you posted this page, so I can remember how to use “top” and “ps aux”, or maybe I’d forget. I walk frequently, so I don’t typically forget how to walk, but if I do, I will just “google it”.

  19. Wonderful article, cyberciti. Linux and Unix are not particularly easy systems for neophytes fed to date by the Windows spoon. Many commands are weird short sequences of bald alphanumeric characters, and the hot sequences to use for a given task just have to be learned and accumulated starting from a blank slate.

    Please could you consider possibly doing another “How To” article, this time on the seemingly impenetrable technical subject of “How Linux Users can express their disagreements with each other in a civil and dignified manner”.

  20. Vivek,
    I am a security professional working with Linux since almost when it first came out. I just wanted to take a moment and thank you for your post. I don’t think any of us here are “experts”. It’s nice to see someone that reminds us of commands that can be easily forgotten or overlooked. Keep up the good work my friend!
    Yoodle

Leave a Comment