Here I am documenting few useful linux terminal command:
-
Command to report system disk space usage:
[osao@slc01nga ~]dfFilesystem 1K-blocks Used Available Use% Mounted on/dev/xvda2 195592588 177362320 8294652 96% /tmpfs 3931448 368 3931080 1% /dev/shm/dev/xvda1 1007896 124588 832108 14% /bootslcnas411:/export/home1/osao16106127360 8378327360 7727800000 53% /home/osao10.246.4.40:/vol/ade_infra/prod/LINUX.X64100663296 5784768 94878528 6% /usr/dev_infra/platform10.246.4.37:/vol/ade_infra/prod/GENERIC100663296 5784768 94878528 6% /usr/dev_infra/genericslc1001nap:/vol/local/x86_64/redhat/60_prod/packages1132462080 1087278784 45183296 97% /usr/local/remote/packagesslc1001nap:/vol/local/linux/redhat/packages1132462080 1087278784 45183296 97% /usr/local/redhat/packagesCommand to see these in summarised short form
[osao@slc01nga ~]df -lhk -
Command for knowing all services running on a machine
[osao@slc01nga ~] nmap localhost (in place of localhost you can give other live machine also in your intranet)
- Command for knowing a port number for service running and Process ID (pid)
[osao@slc01nga ~]netstat -anp | grep 9000 (it will search a service running on port no. 9000)
The following two command will also do the same:
[osao@slc01nga ~] lsof -w -n -i tcp:8080
[osao@slc01nga ~] fuser -n tcp 8080 - Command for knowing Directory/File size
[osao@slc01nga ~]du -hs - Command for searching particular string in particular files in regular expression form
For ex. here we are searching in all files whose name end contains .jspx or .jsff and file contains text "encoding"
[osao@slc01nga ~]grep -H -r -n -i --color "encoding" . --include='*.[j][s][fp][xf]' - Perl Command to replace all occurences of string to other string
the format is
[osao@slc01nga ~]/usr/bin/perl -p -i -e "s/string1/string2/g"
For Ex. for converting all occurences of "ReSult" to "" We will invoke the command
[osao@slc01nga ~] /usr/bin/perl -p -i -e "s/ReSuLt/$Result_Count<\\/font>/g"


