filter text

Less,more = page reader

head = 1st 10 line read

tail = last 10 line default

sort ::

cat /etc/passwd | sort


grep 

search for pattern

cat /etc/passwd | grep "/bin/bash"

exclude pattern with -

cat /etc/passwd | grep -v "false\|nologin"


cut

 cat /etc/passwd | grep -v "false\|nologin" | cut -d":" -f1


-f specifies field

-d delimiter (separator)  

TR

replace characters with others

first option, we define which character we want to replace, and as a second option, we define the character we want to replace it with

 cat /etc/passwd | grep -v "false\|nologin" | tr ":" " "


column

displays in column  form

cat /etc/passwd | grep -v "false\|nologin" | tr ":" " " | column -t


awk

first ($1) and last ($NF) result of the lin

cat /etc/passwd | grep -v "false\|nologin" | tr ":" " " | awk '{print $1, $NF}'


sed

The "s" flag at the beginning stands for the substitute command. Then we specify the pattern we want to replace. After the slash (/), we enter the pattern we want to use as a replacement in the third position. Finally, we use the "g" flag, which stands for replacing all matches.

cat /etc/passwd | grep -v "false\|nologin" | tr ":" " " | awk '{print $1, $NF}' | sed 's/bin/HTB/g'

wc

count lines

cat /etc/passwd | grep -v "false\|nologin" | tr ":" " " | awk '{print $1, $NF}' | wc -l


ss -l -4 | grep -v "127\.0\.0"

  • -l: show only listening services
  • -4: show only ipv4
  • -grep -v "127.0.0": exclude all localhost results

netstat -ln4 | grep LISTEN | grep -v 127


curl https://www.inlanefreight.com > htb.txt && cat htb.txt | tr " " "\n" | cut -d"'" -f2 | cut -d'"' -f2 | grep "www.inlanefreight.com" | sort -u | wc -l