Listing system processes and displaying memory & CPU usage

System Processes

To list the running processes from within a terminal/ shell, type the command top.


/$ top

OUTPUT:
top - 21:23:56 up 5:25, 3 users, load average: 0.04, 0.08, 0.27
Tasks: 195 total, 1 running, 194 sleeping, 0 stopped, 0 zombie
Cpu(s): 9.1%us, 2.1%sy, 0.0%ni, 88.8%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 3025620k total, 2349540k used, 676080k free, 86940k buffers
Swap: 13631116k total, 0k used, 13631116k free, 1798184k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1473 root 20 0 81692 33m 14m S 10 1.1 11:38.01 Xorg
4659 root 20 0 93804 22m 17m S 13 0.8 0:20.23 gnome-system-mo
3632 root 20 0 95176 14m 10m S 4 0.5 0:07.93 gnome-terminal
...
...
...

Memory usage

vmstat n gives the memory usage cyclically every “n” seconds.
Example

/$ vmstat 3

Sample output:
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
r b swpd free buff cache si so bi bo in cs us sy id wa
0 0 0 542736 90120 1815648 0 0 30 47 417 13 22 3 75 1
1 0 0 542604 90120 1815660 0 0 0 0 222 360 0 1 99 0
0 0 0 542604 90140 1815660 0 0 0 45 239 416 0 1 97 2

CPU usage

Similarly, iostat command is used to monitor the CPU usage.

/$ iostat n

Viewing, Creating and Removing an Alias in Unix / Linux

An alias in unix or linux is a shortcut to a command and its switches.

To view existing aliases, type alias in a terminal:

/$ alias

OUTPUT:

alias h='cd /home'
alias l='ls -CF'
alias la='ls -A'
alias ll='ls -alF'
alias ls='ls --color=auto'

In the example above, if you frequently use a certain directory such as /home/myuser/downloads. Create an alias for this directory for easy access by typing,


alias d='cd /home/myuser/downloads'

After the above statement is executed on the terminal, typing d and pressing ENTER will change current directory to /home/myuser/downloads.

Finally, if you want to remove a previously created alias.

Type:


unalias d