Student created untested extra material (comments alo.peets@ut.ee)
*top utilities
top (table of processes) - console command, which outputs the list of working processes and information about them. By default, it sorts processes by their CPU usage in real-time.
The command top works on all UNIX operation systems.
Here you can look an example of the output:

atop
atop has two modes - collecting statistics and system monitoring in real-time. In the first mode, atop runs every N mins (usually its 10 mins) and write current system's state to the log. Then you can look at that log with command atop -r pathtofile.log.
Instead of top, atop knows about network interfaces and can show their usage in percentages.
Here you can look an example of the output:

htop
htop only shows you current system's state like top, but it has a toolbar which help you navigate between processes, sort them, search, kill etc. Mach more pretty and useful.
Here you can look an example of the output:

iftop
iftop is a special utility which allows you to monitor internet traffic in real-time. It requires root prereligious.
Here you can look an example of the output:

dnstop
dnstop analyze DNS traffic on the specific interface.
Here you can look an example of the output:

mytop
mytop shows you connections and basic statistic on the MySQL server.
Here you can look an example of the output:

GREP
grep is an acronym for "search globally for lines matching the regular expression, and print them". This is very good explanation.There are several ways how to grep files:
1.
cat /var/run/dmesg.boot | grep CPU: 2.
grep CPU: /var/run/dmesg.boot 3.
</var/run/dmesg.boot grep CPU: Very often yon need to count founded lines:
1. With wc
grep WARNING /var/run/dmesg.boot | wc -l 2. With key -c
grep WARNING /var/run/dmesg.boot -c Lets create a test file with the following content:
one two three
seven eight one eight three
thirteen fourteen fifteen
sixteen seventeen eighteen seven
sixteen seventeen eighteen
twenty seven
one 504 one
one 503 one
one 504 one
one 504 one
#comment UP
twentyseven
#comment down
twenty1
twenty3
twenty5
twenty7Key -w allows us to search for the full word:
root@maxhp:/ # grep -w 'seven' test.txt
seven eight one eight three
sixteen seventeen eighteen seven
twenty sevenYou can search by the start or the end of the word:
root@maxhp:/ # grep '\<seven' test.txt
seven eight one eight three
sixteen seventeen eighteen seven
sixteen seventeen eighteen
twenty seven
root@maxhp:/ # grep 'seven\>' test.txt
seven eight one eight three
sixteen seventeen eighteen seven
twenty seven
twentysevenOr by the start or the end of the line:
root@maxhp:/ # grep '^seven' test.txt
seven eight one eight three
root@maxhp:/ # grep 'seven$' test.txt
sixteen seventeen eighteen seven
twenty seven
twentysevenIf you want to see not only founded line but some lines before and after, use key -C:
root@maxhp:/ # grep -C 1 twentyseven test.txt
#comment UP
twentyseven
#comment downOr just before or after:
root@maxhp:/ # grep -A 1 twentyseven test.txt
twentyseven
#comment down
root@maxhp:/ # grep -B 1 twentyseven test.txt
#comment UP
twentysevenIf you want to find only lines with twenty1, twenty2, twenty3, twenty4, you dont need to specify all the variants, you can do this:
root@maxhp:/ # grep "twenty[1-4]" test.txt twenty1 twenty3
Or if you want to exclude those lines:
root@maxhp:/ # grep "twenty[^1-4]" test.txt
twenty seven
twentyseven
twenty5
twenty7Lets do real practical example with resolv.conf
Lets see what is inside resolv.conf:
root@maxhp:/ # cat /etc/resolv.conf #options edns0 #nameserver 127.0.0.1 nameserver 8.8.8.8 nameserver 77.88.8.8 nameserver 8.8.4.4
Now, we want to select only lines with IP addresses. For this purpose we need to use reqular expressions, you can read about it here. Key -E tells that we are going to use regular expressions:
root@maxhp:/ # grep -E "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" /etc/resolv.conf
#nameserver 127.0.0.1
nameserver 8.8.8.8
nameserver 77.88.8.8
nameserver 8.8.4.4
Or with this way:root@maxhp:/ # grep -E '\b[0-9]{1,3}(\.[0-9]{1,3}){3}\b' /etc/resolv.conf
#nameserver 127.0.0.1
nameserver 8.8.8.8
nameserver 77.88.8.8
nameserver 8.8.4.4But we dont want commented line:
root@maxhp:/ # grep -E '\b[0-9]{1,3}(\.[0-9]{1,3}){3}\b' /etc/resolv.conf | grep -v '#'
nameserver 8.8.8.8
nameserver 77.88.8.8
nameserver 8.8.4.4
As you can see you can combine greps. Key -v invers search. So it selects everything but founded lines.But we want to select just IP's:
root@maxhp:/ # grep -v '#' /etc/resolv.conf | grep -oE '\b[0-9]{1,3}(\.[0-9]{1,3}){3}\b'
8.8.8.8
77.88.8.8
8.8.4.4
Key -o selects non-empty lines.