1.Grep Command in Linux/Unix Examples :
a.Find the word present in a file
grep <word> <filename>
b.Find the word present in the current and sub directories
grep -r <word> .
"." <dot> represents the current directory and "-r" represents recursive
2.df command for disk free space in linux
[ivreddy@localhost test]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 16G 4.0G 11G 27% /
tmpfs 1012M 432K 1012M 1% /dev/shm
/dev/sda1 291M 30M 247M 11% /boot
/dev/sr0 46M 46M 0 100% /media/Reliance
[ivreddy@localhost test]$
3.top command gives an ongoing look at processor activity in real time. It displays a listing of the most CPU-intensive tasks on the system
[admin@localhost test]$ top
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1942 root 20 0 75076 26m 8372 S 10.3 1.3 2:34.03 Xorg
2381 admin 20 0 315m 55m 23m S 3.3 2.7 4:56.94 firefox
2357 admin 20 0 51096 12m 9496 S 2.3 0.6 0:12.77 gnome-terminal
8161 admin 20 0 2676 1116 868 R 0.7 0.1 0:00.20 top
2242 admin 20 0 91836 21m 16m S 0.3 1.1 0:44.49 vmtoolsd
1 root 20 0 2852 1408 1192 S 0.0 0.1 0:02.27 init
4.sort command in linux
[ivreddy@localhost Desktop]$ cat file
linux
dos
unix
windows
unix
[ivreddy@localhost Desktop]$ sort file
dos
linux
unix
unix
windows
// sort -u <file> will display the uniq records
[ivreddy@localhost Desktop]$ sort -u file
dos
linux
unix
windows
// sort -r <file> will display the records in reverse order
[ivreddy@localhost Desktop]$ sort -r file
windows
unix
unix
linux
dos
[ivreddy@localhost Desktop]$
2.df command for disk free space in linux
[ivreddy@localhost test]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 16G 4.0G 11G 27% /
tmpfs 1012M 432K 1012M 1% /dev/shm
/dev/sda1 291M 30M 247M 11% /boot
/dev/sr0 46M 46M 0 100% /media/Reliance
[ivreddy@localhost test]$
3.top command gives an ongoing look at processor activity in real time. It displays a listing of the most CPU-intensive tasks on the system
[admin@localhost test]$ top
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1942 root 20 0 75076 26m 8372 S 10.3 1.3 2:34.03 Xorg
2381 admin 20 0 315m 55m 23m S 3.3 2.7 4:56.94 firefox
2357 admin 20 0 51096 12m 9496 S 2.3 0.6 0:12.77 gnome-terminal
8161 admin 20 0 2676 1116 868 R 0.7 0.1 0:00.20 top
2242 admin 20 0 91836 21m 16m S 0.3 1.1 0:44.49 vmtoolsd
1 root 20 0 2852 1408 1192 S 0.0 0.1 0:02.27 init
4.sort command in linux
[ivreddy@localhost Desktop]$ cat file
linux
dos
unix
windows
unix
[ivreddy@localhost Desktop]$ sort file
dos
linux
unix
unix
windows
// sort -u <file> will display the uniq records
[ivreddy@localhost Desktop]$ sort -u file
dos
linux
unix
windows
// sort -r <file> will display the records in reverse order
[ivreddy@localhost Desktop]$ sort -r file
windows
unix
unix
linux
dos
[ivreddy@localhost Desktop]$
No comments:
Post a Comment