Linux Troubleshooting Commands

Hi Guys,

I have just updated the Linux troubleshooting command perhaps it might come handy someday. This should assist with your daily Linux administration

netstat -tanp | grep ':80 ' | grep httpd | awk '{print $6}' | sort | uniq -c | sort -n

date >>~//cpu_and_memory_utilization.log && /bin/ps -eo pmem,pcpu,rss,vsize,args | sort -k 1 -r | head -n 8 >> ~/cpu_and_memory_utilization.log

 

==================================================================================================================================================

############ CPU and Memory ###################

ps -eo euser,ruser,suser,fuser,f,comm,label

ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10

strace -o output.txt /bin/foo

strace -p 22254 -s 80 -o /tmp/debug.lighttpd.txt

strace -e trace=open,read -p 22254 -s 80 -o debug.webserver.txt

ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10

ps -eo pmem,pcpu,rss,vsize,args | sort -k 1 -r | head -n 8

ps -eo pcpu,pid,user,args | sort -r -k1 | less

ps -eo pcpu,pid,user,args | sort -k 1 -r | head -6

top -b -n 1 | head -n 12  | tail -n 5

top -o cpu -l 2 -n 5 | tail -n 6

top -o cpu -l 2 -n 5 -stats pid,command,cpu | tail -n 6

top -o cpu -l 2 -n 5 -stats pid,command,cpu -U $(logname) | tail -n 6

 

ps -eo pmem,pcpu,rss,vsize,args,user,euser,ruser,suser,fuser,f,comm,label,pid | sort -k 1 -r | head -n 8

==================================================================

ps -e -o pid,args --forest

ps -f  -p 25009,7258,2426

ps -f --ppid 9576

ps -p 1,29675 -o pid,etime=

ps -C java -L -o pid,tid,pcpu,state,nlwp,args

ps aux --sort pmem

ps ev --pid=27645

ps aux | less

iostat -xtc 5 3

iostat -x sda sdb 2 6

iotop

cat <(grep 'cpu ' /proc/stat) <(sleep 1 && grep 'cpu ' /proc/stat) | awk -v RS="" '{print ($13-$2+$15-$4)*100/($13-$2+$15-$4+$16-$5)}'

sar -o file-name 60 10

nohup sar -A -o output-file 60 10 1>/dev/null 2>&1 &

sar -f output-file (to display the data use -f)

watch "ps aux | sort -kr 3,3 | head -n 6"

ps aux | sort -kr 3,3 | head -n 6

 

pv -t -r -a -b /dev/zero |nc -v -v  -n IP port > /dev/null

nc  -v -v -n port > /dev/null

 

nc l port server

dd if=/dev/zero bs=9100004096 count=1 |nc IP

 

netsstat -r

pa aux |grep -i nfs

 

 

free -m | grep Mem | awk '{print ($3 / $2)*100}'

free -m | grep -i Swap | awk '{print ($3 / $2)*100}'

top -n 1 -b | egrep "PID|updatedb"

 

     14 /abinitio/app/abinitio-app-hub/bin/sdb

     16 /abinitio/app/abinitio-app-hub/bin/agent

     23 -bash

     34 sshd:

    416 [ext4-dio-unwrit]

[root@pabm101zatcrh ~]# ps aux | awk '{print $1}' | sort | uniq -c | sort -nk1 | tail -n5

      4 vwyke

      8 csgmon

      8 hpsmh

    233 abmprd

   1133 root

[root@pabm101zatcrh ~]#

 

 

 

---------------------------------------

CPU ----

----

/usr/platform/`uname -`/sbin/prtdiag

mpstat -P ALL

ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10

ps -eo pcpu,pid,user,args | sort -r -k1 | less

 iostat -xtc 5 3

top -bn1 | grep "Cpu(s)" | \

           sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | \

           awk '{print 100 - $1"%"}'

 

                                  

top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | \  awk '{print 100 - $1"%"}'

mpstat | awk '$12 ~ /[0-9.]+/ { print 100 - $12"%" }'

ps -e -o %mem,%cpu,cmd | grep httpd | awk ' {memory+=$1;cpu+=$2} END {printf("%05.2f ",memory);printf("%05.2f\n",cpu)}'

ps -e -o %mem,%cpu,cmd,pmem,pcpu,rss,vsize,args | awk ' {memory+=$1;cpu+=$2} END {printf("%05.2f ",memory);printf("%05.2f\n",cpu)}'

top -bn 2 -d 0.01 | grep '^Cpu.s.' | tail -n 1 | gawk '{print $2+$4+$6}'

##############################################################################################################

################# Network Troubleshooting Command ################

[root@dha3323ddserver ~]# ss -t -a -Z dha3323ddstorage

ss: SELinux is not enabled.

[root@dha3323ddserver ~]#

ss -u -a

              Display all UDP sockets.

 

       ss -o state established '( dport = :ssh or sport = :ssh )'

              Display all established ssh connections.

 

       ss -x src /tmp/.X11-unix/*

              Find all local processes connected to X server.

 

       ss -o state fin-wait-1 '( sport = :http or sport = :https )' dst 193.233.7/24

              List all the tcp sockets in state FIN-WAIT-1 for our apache to network 193.233.7/24 and look at their timers.

 

ping -c 4 8.8.8.8

mtr dha3323ddstorage

mtr -c 4 google.com

mtr --report google.com

traceroute -4 8.8.8.8

tracepath 8.8.8.8

ip link show

ip link set eth0 up

ip -br link show

ifconfig eth0 192.168.50.5 netmask 255.255.255.0

ifup eth0

ifdown eth0

ifconfig eth0 mtu XXXX

ifconfig eth0 - promisc

ping -c 5 www.tecmint.com

netstat -r

netstat -tnlp

nc -zv server2.tecmint.lan 21 22 80 443 3000

nc -zv server2.tecmint.lan 20-90

nc -p 3000 -w 10 server2.tecmint.lan 5000

nmap google.com

tcpdump -i eth1

tcpdump -c 5 -i eth1

tcpdump -w captured.pacs -i eth1

Wireshark

Bmon Tool

netstat -an |grep LISTEN

curl or wget

ifplugstatus

dig www.tecmint.com

iftop

dig google.com ANY

host www.google.com (CNAME, NS, MX, SOA) host -t CNAME www.redhat.com

ip route show 10.0.0.0/8

ss -tunlp4

ss -ta

ss -to

ss -at

ss -au

ss -ax

ss -ap

ss -t4 state closed

ss dst 192.168.0.1

ss src 192.168.0.2

ss dport != :53

ss 192.168.0.1:http

ss dst 192.168.0.1/24

ss dst XXX.XXX.XXX.XXX:22

lsblk

lsof -i

ss | grep 58620

telnet database.example.com 3306

nslookup -type=ns jhah.com

nslookup -query=nx jhah.com

dig -x jhah.com ANY

 

#######: To list of kill signals:###########

kill -l

1) SIGHUP  2) SIGINT   3) SIGQUIT  4) SIGILL

5) SIGTRAP  6) SIGABRT  7) SIGEMT   8) SIGFPE

9) SIGKILL 10) SIGBUS  11) SIGSEGV 12) SIGSYS

13) SIGPIPE 14) SIGALRM 15) SIGTERM 16) SIGURG

17) SIGSTOP 18) SIGTSTP 19) SIGCONT 20) SIGCHLD

21) SIGTTIN 22) SIGTTOU 23) SIGIO 24) SIGXCPU

25) SIGXFSZ 26) SIGVTALRM 27) SIGPROF 28) SIGWINCH

29) SIGINFO 30) SIGUSR1 31) SIGUSR2

Comments

Popular posts from this blog

Push command for NetWorker Client Upgrade

Factors Affecting Users’ Sense of Security and Trust in Integrating Electronic health record to the cloud

Basic Elastic Cloud Storage Troubleshooting Commands