Friday 19 September 2014

Linux command line : Process Management

Process management

The Linux terminal has a number of useful commands that can display running processes, kill them, and change their priority level. This post lists the classic, traditional commands, as well as some more useful, modern ones.
Many of the commands here perform a single function and can be combined — that’s the Unix philosophy of designing programs. Other programs, like htop, provide a friendly interface on top of the commands.
top
The top command is the traditional way to view your system’s resource usage and see the processes that are taking up the most system resources. Top displays a list of processes, with the ones using the most CPU at the top.

htop

The htop command is an improved top. It’s not installed by default on most Linux distributions — here’s the command you’ll need to install it on Ubuntu:
sudo apt-get install htop
htop displays the same information with an easier-to-understand layout. It also lets you select processes with the arrow keys and perform actions, such as killing them or changing their priority, with the F keys.

ps

The ps command lists running processes. The following command lists all processes running on your system:
ps -A

This may be too many processes to read at one time, so you can pipe the output through theless command to scroll through them at your own pace:
ps -A | less


kill

The kill command can kill a process, given its process ID. You can get this information from theps -A, top or pgrep commands.
kill PID

pkill & killall

The pkill and killall commands can kill a process, given its name. Use either command to kill Firefox:
pkill firefox
killall firefox




1 comment:

  1. Great tips, many thanks for sharing. I have printed and will stick on the wall! I like this blog. Best Therapist San Francisco

    ReplyDelete