
Terminal - Commands using sort - 537 results
last | grep -v "^$" | awk '{ print $1 }' | sort -nr | uniq -c
This is sample output - yours may be different.
1 wtmp
2 reboot
31 oracle
15 jsmith
142 jdoe
3 root
This command takes the output of the 'last' command, removes empty lines, gets just the first field ($USERNAME), sort the $USERNAMES in reverse order and then gives a summary count of unique matches.
diff <(sort file1.txt) <(sort file2.txt)
This is sample output - yours may be different.
Sees if two records differ in their entries, irrespective of order.
history | awk '{print $2}' | sort | uniq -c | sort -rn | head
This is sample output - yours may be different.
egrep -o '\b[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\b' access.log | sort -u
This is sample output - yours may be different.
find path/to/folder/ -type f -print0 | xargs -0 -n 1 md5sum | awk '{print $1}' | sort | md5sum | awk '{print $1}'
This is sample output - yours may be different.
798231bfb8892963eddffda0deb6b381
For quick validation of folder's file-contents (structure not taken into account) - I use it mostly to check if two folders' contents are the same.
netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n | tail
This is sample output - yours may be different.
[root@vps10 root]# netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n | tail
8 200.217.193.102
8 82.101.189.139
9 84.195.188.60
11 189.63.98.3
11 60.28.166.169
13 24.227.166.150
15 200.214.44.134
16 189.92.141.77
22 189.14.101.44
31 127.0.0.1
This command does a tally of concurrent active connections from single IPs and prints out those IPs that have the most active concurrent connections. VERY useful in determining the source of a DoS or DDoS attack.
ps -eo pcpu,pid,args | sort -n
This is sample output - yours may be different.
0.8 25686 gnome-terminal
1.3 23966 /usr/lib/thunderbird/thunderbird-bin
35.9 6638 /usr/lib/firefox-3.0.6/firefox
Useful to detect which process is causing system loads. It shows process PID so as we can take further actions.
This is sample output - yours may be different.
4 mvc_example.php
72 caseconverter
80 contact
248 hangman
Very useful for finding the largest files and subdirectories at any given point. Any user can run it from current location just when need to know their largest files and subtdirectories from a certain point down as well.
netstat -anl | grep :80 | awk '{print $5}' | cut -d ":" -f 1 | uniq -c | sort -n | grep -c IPHERE
This is sample output - yours may be different.
This will tell you who has the most Apache connections by IP (replace IPHERE with the actual IP you wish to check). Or if you wish, remove | grep -c IPHERE for the full list.
netstat -pant 2> /dev/null | grep SYN_ | awk '{print $5;}' | cut -d: -f1 | sort | uniq -c | sort -n | tail -20
This is sample output - yours may be different.
1 125.162.92.184
1 125.164.121.250
1 125.71.93.177
1 128.107.229.110
1 189.147.101.11
1 202.40.210.145
1 202.40.210.164
1 203.130.201.198
1 41.201.190.148
1 41.201.238.148
1 81.199.44.161
1 81.202.11.253
2 202.134.71.158
7 218.4.59.190
List top 20 IP from which TCP connection is in SYN_RECV state.
Useful on web servers to detect a syn flood attack.
Replace SYN_ with ESTA to find established connections
du -hs * | grep '^[0-9,]*[MG]' | sort -rn
This is sample output - yours may be different.
170M Richard Stevens TCP-IP Illustrated Vol 2.pdf
153M Richard_Stevens_UNIX_Network_Programming_Sec_Ed_Vol_1.pdf
126M Rederik_Smith_Full_Docs_FreeBSD_rus.pdf
117M WhiteParus.Unix.Rukovodstvo_Sysadmina.pdf
115M Richard_Stevens_Advanced_Programming_in_the_UNIX_Environment.pdf
89M Richard Stevens Tcp-Ip Illustrated Vol 1.pdf
80M Richard_Stevens_UNIX_Network_Programming_Sec_Ed_Vol_2.pdf
73M IEEE
22M tannenbaum
netstat -anp |grep 'tcp\|udp' | awk '{print $5}' | sed s/::ffff:// | cut -d: -f1 | sort | uniq -c | sort -n
This is sample output - yours may be different.
14 111.111.111.111
28 123.123.123.123
34 0.0.0.0
usefull in case of abuser/DoS attacks.
find -printf '%u %g\n' | sort | uniq
This is sample output - yours may be different.
apache apache
root root
user1 apache
find -printf '%u\n' | sort | uniq #just users
find -printf '%g\n' | sort | uniq #just groups
history | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head
This is sample output - yours may be different.
sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4 /file/of/ip/addresses
This is sample output - yours may be different.
find / -xdev -size +1024 -exec ls -al {} \; | sort -r -k 5
This is sample output - yours may be different.
ls -la | awk '{print $5, " " ,$9}' | sort -rn
This is sample output - yours may be different.
last | awk '{ print $1 }' | sort | uniq -c | grep -v wtmp
This is sample output - yours may be different.
sed -e 's/ *$//' ~/.bash_history | sort | uniq -cd | sort -nr | head
This is sample output - yours may be different.
kill -HUP ` ps -aef | grep -i firefox | sort -k 2 -r | sed 1d | awk ' { print $2 } ' `
This is sample output - yours may be different.
Imaging a Firefox window disappearing :-)
(It kills the hanging firefox process.)
# cut -d ' ' -f1 /var/log/nginx/nginx-access.log | sort | uniq -c | sort -nr | head -10 | nl
This is sample output - yours may be different.
perl -pe 's/.+;//' ~/.zsh_history | sort | uniq -c | sort -r|head -10
This is sample output - yours may be different.
3940 ls
1427 sudo emerge -vpuDN world
1084 top
684 tail /var/log/samba/log.smbd -n 50
601 sudo emerge --sync
573 sudo emerge --depclean
566 ls -alh
561 df -ah
523 cd
430 sudo revdep-rebuild
cd ~/.purple/logs/; egrep -ri "i can haz|pwn|l33t|w00|zomg" * | cut -d'/' -f 3 | sort | uniq | xargs -I {} echo "Note to self: ban user '{}'"
This is sample output - yours may be different.
Note to self, ban user 'aoluser'
Note to self, ban user 'msnuser'
Greps IRC logs for phrases and lists users who said them.
find $PWD -exec rpm --query -f {} \; | sort -u | grep -v "not owned"
This is sample output - yours may be different.
shows all RPMs with files in the current directory & its subdirectories.
netstat -ant | awk '{print $NF}' | grep -v '[a-z]' | sort | uniq -c
This is sample output - yours may be different.