🐧 Linux运维命令手册
涵盖 VIM · 文件系统 · 进程管理 · 网络 · Nginx · Docker · K8s 八大核心章节
📝 一、VIM 编辑器——必会基础
h j k l / w b 0 $ gg G
i a o I A O
yy p dd u Ctrl+r
/keyword :%s/old/new/g
:wq :q! :w
⚡ 实战技巧:在 ~/.vimrc 中添加 set nu ai ts=4 sw=4 自动开启行号与缩进,效率翻倍。
~/.vimrc
set nu ai ts=4 sw=4
📂 二、文件系统管理
▶ 目录导航与查看
ls -lah
cd - cd ~ cd ..
head -20 f.txt / tail -f f.txt
▶ 文件操作与权限
cp -rp src dst / mv src dst
chmod 755 file / chown user:group file
find / -name "*.conf" 2>/dev/null
tar -czf pkg.tar.gz dir/ / tar -xzf pkg.tar.gz
⚙️ 三、进程与系统管理(含 Systemd)
▶ 进程查看与控制
ps aux | grep nginx
top / htop
kill -9 PID / pkill -f nginx
ss -tlnp / netstat -tlnp
▶ Systemd 服务管理(现代 Linux 标配)
systemctl start/stop/restart nginx
systemctl enable/disable nginx
systemctl status nginx / journalctl -u nginx -f
systemctl daemon-reload
🌐 四、网络管理
ip addr show / ifconfig
ip route / route -n
ping -c 4 8.8.8.8 / traceroute www.baidu.com
nslookup www.baidu.com / dig www.baidu.com
firewall-cmd --add-port=80/tcp --permanent
wget -c url / curl -O url
🚀 五、Nginx 常用命令
nginx -t
nginx -s reload / systemctl reload nginx
tail -f /var/log/nginx/access.log
awk '{print $1}' access.log | sort | uniq -c | sort -rn | head -10
📌 配置路径参考:主配置:/etc/nginx/nginx.conf 虚拟主机:/etc/nginx/conf.d/*.conf 日志:/var/log/nginx/
/etc/nginx/nginx.conf
/etc/nginx/conf.d/*.conf
/var/log/nginx/
🐳 六、Docker 容器管理
▶ 镜像管理
docker pull nginx:alpine
docker build -t myapp:v1 .
docker image prune -a
▶ 容器管理
docker run -d -p 80:80 --name web nginx
docker logs -f web
docker exec -it web /bin/bash
docker compose up -d / docker compose ps
☸️ 七、Kubernetes(K8s)常用命令
▶ 集群与节点
kubectl cluster-info
kubectl get nodes -o wide
▶ Pod 管理
kubectl get pods -A
kubectl describe pod <pod-name> -n <ns>
kubectl logs -f <pod> / kubectl logs -f <pod> -c <container>
kubectl exec -it <pod> -- /bin/bash
▶ 工作负载与配置
kubectl scale deploy/nginx --replicas=3
kubectl get svc -A
kubectl apply -f deploy.yaml
kubectl get events -n <ns> --sort-by=.lastTimestamp
🖥️ 八、系统信息速查
cat /etc/os-release / uname -a
lscpu / nproc
free -h
df -h / lsblk
uptime / top -n 1 | head -5
env / echo $PATH
🎯 写在最后
以上命令覆盖了 Linux 运维日常 80% 的高频场景。真正的熟练不在于死记硬背,而在于理解每条命令背后的逻辑。
建议把本文加入收藏,遇到问题先查再 Google,久而久之这些命令就会变成你的肌肉记忆。💪
📌 关注辉哥,持续更新运维实战干货
Linux · K8s · 阿里云 · 中医养生 · 书法赏析