Linux 常用命令备忘
日常操作中最常用的一批命令,按用途分组,方便随时查阅。
文件与目录
ls -alh # 列出文件(含隐藏、可读大小)
cd /path/to/dir # 切换目录
cp -r src dst # 复制(-r 用于目录)
mv old new # 移动 / 重命名
find . -name "*.log" # 按文件名查找
查看与检索
cat file # 输出全文
less file # 翻页查看(q 退出)
tail -f app.log # 实时跟踪日志
grep -rn "keyword" . # 递归搜索并显示行号
进程与服务
ps aux | grep xxx # 查找进程
top # 实时资源占用
systemctl status nginx # 查看服务状态
systemctl enable --now nginx # 设置开机自启并立即启动
网络排查
ss -tlnp # 查看监听端口
curl -I https://example.com # 只看响应头
dig +short example.com # 查询 DNS 解析