Linux Common Commands

Linux Common Commands
后台运行
  • nohup ssserver > log &
locate

Linux locate updatedb
Mac locate sudo /usr/libexec/locate.updatedb

zip split

zip -r -s 50m /folder #以50MB一片,分片压缩

Zip including hidden files

zip yourfile.zip sourcedir/* .*

check CentOS version

rpm --query centos-release
lsb_release -d #vps上的CentOS被改动过,uname -a 已经看不到CentOS版本号了

进程与资源

ss -l -p -n | grep ",1234,"
lsof -Pan -p PID -i
ps -aef | grep httpd
ps -C firefox -o pid=
ps aux | grep {program-name}
ls -l /proc/{PID}/fd
lsof -p {PID}
lsof -a -p {PID}
pidof mysqld
cat /proc/{PID}/net/sockstat
fuser {FILENAME}
lsof {FILENAME}

端口

sudo netstat -plunt
sudo nmap -p portnumber remotehost
nc -z -v {host-name-here} {port-range-here}
nc -z -v host-name-here 22

reference1
reference2

Docker 允许容器访问宿主机 比如访问宿主redis

iptables -A INPUT -i br-c795f5f4af3d -j ACCEPT

查找文件并展示文件大小

locate json.log | xargs du -sh

列出当前文件夹一层子文件夹大小

du -h --max-depth=1 | sort -hr
du -a -h --max-depth=1 | sort -hr

Related Article