Featured image of post Common unix-like commands

Common unix-like commands

Some commonly used unix-like commands.

Overview

This article summarizes frequently used Unix-like system commands for daily development, troubleshooting, and system monitoring. Each command includes practical usage examples and brief explanations to help you quickly find and understand essential tools.

Commands

tcpdump

1
sudo tcpdump -i any src port 13400 or dst port 13400

mount

1
mount -o remount,rw <path>

ps (process status)

1
2
3
4
5
6
ps aux | grep <-i> <xxx>

# check related precess information and reserver first line.
ps -eo pid,ppid,user,cmd | awk 'NR==1 || /<key_word>/' | less -S
# sz: viture memory usage, unit: page/4k, 
ps -eo pid,ppid,user,cmd,pcpu,sz,rss | awk 'NR==1 || /<key_word>/' | less -S

vmstat

1
2
#check virtual memory usage
vmstat -Sm 1

top

  1. Type Shift + P: Sort by CPU load in descending order
  2. Type Shift + M: Sort by memory usage in descending order
  3. Type c: Show complete command.
  4. Type E: Switching unit.

Network

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
lsof -i :<port> # check port's process

# -t: TCP, -u: UDP, -l: only listening, -n: don't parse servername, 
# -p: show port process information
ss -tulnp | grep <"process name"> 

ss -tulnp | grep <":port">

# show first line title
ss -an | awk 'NR==1 || /:13400/'
comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy