Linux Cut, Paste, Sort, Uniq, Tr, and Egrep - lets play
In this video we will play with the linux commands cut, paste, sort, uniq, tr, and egrep. We will do this by looking at the history of logged in users with last as well as looking for config files with passwords in them.
Commands in the video
2 man cut
3 man paste
4 man sort
5 last
6 last | grep -v ^reboot
7 last | grep -v ^reboot | more
8 last | grep -v ^reboot | tr -s ' '
9 man tr
10 last | grep -v ^reboot | tr -s ' ' | cut -d " " -f 1,5-
11 last | grep -v ^reboot | tr -s ' ' | cut -d " " -f 1
12 last | grep -v ^reboot | tr -s ' ' | cut -d " " -f 1 | sort
13 last | grep -v ^reboot | tr -s ' ' | cut -d " " -f 1 | sort | uniq
14 last | grep -v ^reboot | tr -s ' ' | cut -d " " -f 1 | sort | uniq 2(NOT ALLOWED) /dev/null
15 last | grep -v ^reboot | tr -s ' ' | cut -d " " -f 1 | sort | uniq | grep -v wtmp
16 ls
17 rm -rf playing/
18 mkdir playing
19 cd playing
20 for letter in {A..Z} ; do echo ${letter} (NOT ALLOWED) letter; done
21 more letter
22 more letter | wc -l
23 export x=0
24 while [ $x -le 25 ]; do echo "$x" (NOT ALLOWED) number; (( x++ )); done
25 more number
26 more number | wc -l
27 cat letter number
28 paste number letter
29 paste number letter letter number letter
30 man paste
31 paste -s number letter letter number letter
32 sudo find /etc -exec egrep -H [P,p][A,a][S,s]{2}[W,w} {} \;
33 sudo find /etc -exec egrep -H [P,p][A,a][S,s]{2}[W,w] {} \;
34 sudo find /etc -exec egrep -H [P,p][A,a][S,s]{2}[W,w] {} \; 2(NOT ALLOWED) /dev/null
35 sudo find /etc -exec egrep -H [P,p][A,a][S,s]{2}[W,w] {} \; 2(NOT ALLOWED) /dev/null | cut -f1 -d :
36 sudo find /etc -exec egrep -H [P,p][A,a][S,s]{2}[W,w] {} \; 2(NOT ALLOWED) /dev/null | cut -f1 -d : | sort | uniq
37 sudo find /etc -exec egrep -H [P,p][A,a][S,s]{2}[W,w] {} \; 2(NOT ALLOWED) /dev/null | cut -f1 -d : | sort | uniq | wc -l
38 sudo find /etc -exec egrep -H [P,p][A,a][S,s]{2}[W,w] {} \; 2(NOT ALLOWED) /dev/null | cut -f1 -d : | wc -l