Chapter 6 Process management in Linux
6.1 top
The top program provides a dynamic real-time view of a running system.
Usually top is used with the option -c.
top -c
The option -c will let top to displat the full command path along with the command arguments in the COMMAND collumn.
You can also run top interactively. You can run top first and then press c. If you want to kill a process with PID of 186, you can press k and then type 186 to kill the process with PID of 186.
man top can help you get the manual of command top.
The following table explains what each column mean.
| Columns | Description |
|---|---|
| PID | Process ID |
| USER | Name of the effective user (owner) of the process |
| PR | Priority |
| NI | Nice value |
| VIRT | Virtual memory size |
| RES | Resident memory size |
| SHR | Shared memory size |
| S | Process status (which could be one of the following: D (uninteruptible sleep), R (running), S (sleeping), T (traced or stopped) or Z (zombie) |
| %CPU | The share of cpu time used by the process since last update |
| %MEM | Share of physical memory used |
| TIME+ | Total cpu time used by the task in hundredths of a second |
| COMMAND | Command name or command line (name + options) |
6.2 ps
The command ps can report a snapshot of the current processes.
Command ps is usually used with the option -a, -u and -x.
ps -aux ## can also be `ps aux`
You can pipe the output to less to make it scrollable.
6.3 kill
If you want to kill a process, you can use the command kill.
kill 20140418
6.4 df
df can be used to report file system disk space usage.
df -h ## Filesystem Size Used Avail Use% Mounted on
## overlay 794G 676G 78G 90% /
## tmpfs 64M 0 64M 0% /dev
## tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
## /dev/sda5 794G 676G 78G 90% /data
## shm 64M 0 64M 0% /dev/shm
## tmpfs 3.9G 0 3.9G 0% /proc/asound
## tmpfs 3.9G 0 3.9G 0% /proc/acpi
## tmpfs 3.9G 0 3.9G 0% /proc/scsi
## tmpfs 3.9G 0 3.9G 0% /sys/firmware
If you Linux cluster, you might need to check other command like myquota.
6.5 Advanced topic free
You can use command free to display amount of free and used memory in the system.
free -h
-h let you show all output fields automatically scaled to shortest three digit unit and display the units of print out. Following units are used.
| Abbreviation | Full Name |
|---|---|
| B | Bytes |
| K | Kilobytes (KB) |
| M | Megabytes(MB) |
| G | Gigabytes (GB) |
| T | Terabytes (TB) |
6.6 Commands for Linux administration (Advanced topic)
6.6.1 w
w shows who is logged on and what they are doing.
w## 03:00:19 up 74 days, 5:28, 0 users, load average: 0.11, 0.23, 0.54
## USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
6.6.2 who
who shows who is logged on
who -a6.6.3 uptime
In Linux uptime command shows since how long your system is running and the number of users are currently logged in and also displays load average for 1,5 and 15 minutes intervals.
uptime## 03:00:19 up 74 days, 5:28, 0 users, load average: 0.11, 0.23, 0.54
6.6.4 whoami
whoami## rstudio
6.6.5 ifconfig
ifconfig can configure a network interface. To me I mostly use it to output the IP address.
ifconfig
6.6.6 useradd and passwd
## Need to have root access
adduser superomics
## add a user to a specified group
adduser superomics -g bioinf