Important Linux Commands

To get the list of username with its user ID in formatted way:-

awk -F":" '{ print "username: " $1 "\t\tuid:" $3 }' /etc/passwd

Find the particular string from the list of files in current directory:-

cd /etc
for i in $(find -type f); do grep -iH nfsnobody $i; done
grep -iH nfsnobody *

Get the number of occurrences of particular word in file:-

awk '/ServerName/ {i=i+1} END {print i}' /etc/httpd/conf/httpd.conf
grep ServerName /etc/httpd/conf/httpd.conf

To delete resources of semaphore arrays from memory:-

ipcs -s | grep apache | perl -e 'while () { @a=split(/\s+/); print`ipcrm sem $a[1]`}'

To get the list of IP addresses in the server:-

ifconfig | grep -vw inet6 | grep -w inet | cut -d : -f 2 | cut -d \ -f 1

Find list of IP address along with eth device and network mask:-

ifconfig | cut -d " " -f1,12,16 | grep -A 1 eth | tr -d - | tr -s "\n" |sed -e :a -e N -e 's/\n/ /'

Change the device address as per your servers configuration:-

hdparm -Tt /dev/sda

To get the listing of directories:-

ls -F $1 | grep \/ | sed -e 's/\/$/4/g'

To Get Real Time Network Activity Examples:-

watch -d "netstat -nalp |grep -v DGRAM |grep -v STREAM |grep -v LISTEN"
watch "netstat -nalp"|grep ":TCP PORT Number"
watch "netstat -nalp"|grep ":22"

The details of the present http connections can be found by using:-

netstat -plan | grep ":80 " | awk {'print $5'} |awk -F: {'print $1'}|sort
cat /proc/net/ip_conntrack | grep "port=80" | wc -l

Number of connection from perticular IP address:-

netstat -ntu | awk '{print $5}'| cut -d: -f1 | sort | uniq -c | sort -nr | more

I'm happy to use Increase Sociability.