This is a oneliner bash command to determine my 10 most used linux commands according to my history file history | awk ‘{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] ” ” CMD[a]/count*100 “% ” a;}’ | grep -v “./” | column -c3 -s ” ” -t | sort -nr | nl | head -n10 The [...]
Posts Tagged: sort
Allow NFS through iptables
This is one way to determine the ports needed to open in your iptables rules to get NFS to work properly. First we need to determine the ports NFS uses rpcinfo -p | awk -F ” ” ‘{print $3 “, ” $4 “, ” $5}’ | sort | uniq Notice! Since portmap assigns ports on [...]
Query RPM database/packages and list their architecture
If you use the –queryformat argument with rpm it is possible to query RPMs for different architectures installed # rpm -qa –queryformat %{NAME}-%{VERSION}-%{ARCH}\\n | grep dbus-glib | sort Result dbus-glib-0.22-12.EL.5-i386 dbus-glib-0.22-12.EL.5-x86_64 This can also be used in one of my previous posts: Remove duplicate packages when querying the rpm database.
Sort IP address
Sorting IP addresses using sort is not easy because the dot confuses sort. This line makes it possible to sort by the whole value of the address sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4 ipaddresses.txt You can also sort by the last octet sort -r. -n +3.0 ipaddresses.txt
List processes in a hierarchy
ps -e -o pid,args –forest List processes by % cpu usage ps -e -o pcpu,cpu,nice,state,cputime,args –sort pcpu | sed ‘/^ 0.0 /d’ List processes by mem usage ps -e -orss=,args= | sort -b -k1,1n | pr -TW$COLUMNS List info for particular process IDs ps -p 1,2
Recent Comments