Using Linux

Using Linux: Viewing All Active Processes & Programs

Sometimes you need to find out what’s going on behind the scenes on your computer system to answer various questions such as, “why is my system running slowly” – “is malicious software installed on my system” – “what can I cut out to maximize performance” etc. Here’s how to do it…

Please note: This brief tutorial is performed using my Ubuntu 16.04 LTS. If your system is running a different version of Linux then I can’t guarantee it will work in the same way. (Just a heads up).


LEVERAGING THE POWER OF “ps”

One of the timeless commands on the Linux system is the “ps” command. It’s been around for a very long time and works on almost every Linux distribution out there. The ps command is used to observe a readout of all currently-running processes and programs on a computer and includes a few various options to change what details are displayed.

So some really awesome news: Installation is not required. If you’re using Linux, then you already have this on your system 😀

A quick not about syntax: The ps command is unusual in that it works with two different styles of syntax (BSD and UNIX). Because of this, you must pay close attention to the specific characters used in the various commands. Using the minus sign (-) in commands will change the entire function of your commands.

So lets get started…

 

1) Display all running processes

$ ps ax

If you would like to include more detailed information about the processes then include the letter “u” like this:

$ ps aux

 

2) Display running processes by user

This will show you which processes are running and which user is responsible for activating the respective processes.

$ ps -f -u USERNAME1

Insert the user’s ID (“user name”) in the section above labeled, “USERNAME1” to find out which processes and programs are currently running which were started by that user. Additional users can be searched by adding commas to separate them like this:

$ ps -f -u USERNAME1,USERNAME2,USERNAME3

(…and so on)

 

3) Display running processes by process name or process ID

You can search for a specific running program (like Telegram messenger, for example) by issuing the following command:

$ ps -C telegram

To search for a process by its ID you must issue a command similar to the one used to search for a specific user (or list of users):

$ ps -f -p 3150,7298,6544

 

4) Sort the list of running processes by CPU/Memory usage

A few quick notes on this section:

  • Numerous sections can be used to sort the outputs of your process list. (See the full list of options by reading the manual by typing “man ps”)
  • Multiple fields can be used to sort the output simultaneously. To do this, just be sure that you separate each sort parameter with a coma (as you did with usernames and process ID’s above)
  • Ascending sort is accomplished by appending  a plus sign to the sort parameter (+)
  • Descending sort is accomplished by app0ending a minus sign to the sort parameter (-)
$ ps aux --sort=-pcpu

Limit the readout of processes to a specific number of lines by piping the response into “head -10” (if you only wish to see 10 results, for example).

$ ps aux --sort=-pcpu | head -10

 

5) Use “ps” with “watch” to view real-time top load processes on your CPU

(This method inspired by BinaryTides)

$ watch -n 1 'ps -e -o pid,uname,cmd,pmem,pcpu --sort=-pmem,-pcpu | head -15'

 


CONCLUSION

Learn more about this topic and other related tools and features on the awesome BinaryTides website located here: http://www.binarytides.com/linux-ps-command/

You can also find a few nuggets of information listed here.

Published by

willinspire

Entrepreneur Cryptocurrency Trader Forex Trader Internationally Published Model Model Coach, Model Scout Published Photographer USMC Veteran Violinist and Pianist Investor Visionary

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s