Skip to content

Instantly share code, notes, and snippets.

@Jongbhin
Last active July 25, 2022 07:42
Show Gist options
  • Save Jongbhin/0498452a5ff09987bbdaa2a222018332 to your computer and use it in GitHub Desktop.
Save Jongbhin/0498452a5ff09987bbdaa2a222018332 to your computer and use it in GitHub Desktop.
[linux command reference] #linux #command #reference

Linux netstat command find out which process is listing upon a port

Find out the process that opened thr port

netstat -tulpn
ls -l /proc/1138/exe

Find out the processes PID that opened tcp port 7000, enter:

fuser 7000/tcp

Find Out Current Working Directory Of a Process

pwdx <pid>

Find Out Owner Of a Process on Linux

ps aux | grep <pid>

Check memory per process

ps -o pid,user,%mem,command ax | sort -b -k3 -r |more

Traceroute

/bin/traceroute -n -w 1 -m 20 -T -p 80 <ip>

apt

Check installed list

apt list --installed

sort tab, 2nd field

sort -n -t$'\t' -k 2 other.tsv > other.sorted.tsv

split

split -l 1000000 -d -a 4  all_input input
# start at number 0350
split -l 100000 --numeric-suffixes=0350 -a 4  other.tsv input

field filtering using awk

awk '{ if ($4 == 1) { print } }' 

replace text in a file using awk

awk '{sub("02/06/2020","12/06/2020")}1' $1 > temp.txt

process killed by OOMkiller

grep -i 'killed process' /var/log/messages
dmesg -T| grep -E -i -B100 'killed process'

Search text in chld directory

grep -rnw --include=\*.{py,sh} . -e "011st.com"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment