本文发布于97 天前,其中的信息可能已经过时,如有错误请发送邮件到supper@vcclient.xyz
于2024/8/10记录
# 📂 目录与路径
pwd 显示当前所在目录
ls -a 显示全部文件(含隐藏)
ls -l 显示详细信息(竖向列表)
ls -lh 以人类可读的方式显示文件大小
cd /path 切换目录
cd .. 返回上一级目录
cd ~ 返回 Home 目录
# 📁 文件与目录操作
mkdir dir 创建目录
mkdir -p a/b/c 递归创建父目录
touch file 创建空文件
cp file1 file2 复制文件
cp -r dir1 dir2 递归复制目录
mv a b 移动或重命名
rm file 删除文件
rm -rf dir 强制删除目录及内容
# 📖 文件内容查看
cat file 查看完整内容
tac file 倒序查看
more file 分页查看(空格翻页,q 退出)
less file 分页查看(支持上下翻动)
head -n 20 file 查看前 20 行(默认 10 行)
tail -n 20 file 查看末尾 20 行(默认 10 行)
tail -f file 实时跟踪文件变化
# 🔍 查找与搜索
which cmd 查找命令路径
whereis cmd 查找命令/帮助文件/源码位置
locate file 按名称快速查找文件(需 updatedb)
find / -name "file" 按文件名查找
find / -size +100M 查找大于 100MB 的文件
grep -n "关键字" file 搜索文件内容(显示行号)
grep -r "关键字" dir 递归搜索目录
grep -i "关键字" file 忽略大小写搜索
# 📊 文件统计
wc -c file 统计字节数
wc -m file 统计字符数
wc -l file 统计行数
wc -w file 统计单词数
# 🔑 权限管理
ls -l 查看权限
chmod 755 file 修改权限(rwxr-xr-x)
chown user file 修改文件所有者
chgrp group file 修改文件所属组
umask 查看默认权限掩码
# 📦 压缩与解压
tar -cvf a.tar dir 打包目录
tar -xvf a.tar 解包
tar -zcvf a.tar.gz dir 压缩为 .tar.gz
tar -zxvf a.tar.gz 解压 .tar.gz
zip -r a.zip dir 压缩为 zip
unzip a.zip 解压 zip
# 👤 用户与组
whoami 显示当前用户名
id 显示 UID/GID 信息
who 显示已登录用户
adduser user 添加用户
passwd user 修改密码
deluser user 删除用户
usermod -aG sudo user 添加用户到 sudo 组
groups user 查看用户所属组
# 🌐 网络命令
ifconfig 查看网络信息(需 net-tools)
ip addr 查看网络信息(推荐)
ping host 测试连通性
curl url 发送 HTTP 请求
wget url 下载文件
netstat -tulnp 查看端口占用(旧)
ss -tulnp 查看端口占用(推荐)
# ⚙️ 进程管理
ps aux 查看进程
top 动态显示进程
htop 更好看的进程管理(需安装)
kill -9 PID 强制杀死进程
pgrep name 查找进程 PID
pkill name 杀死指定进程
# 💽 磁盘与存储
df -h 查看磁盘空间
du -sh dir 查看目录大小
du -h --max-depth=1 dir 查看子目录大小
mount 查看挂载
umount /dev/sdX 卸载设备
# 💻 系统信息
uname -a 查看系统信息
uname -r 查看内核版本
lsb_release -a 查看发行版信息
uptime 查看系统运行时长
who -b 查看最近启动时间
date 显示系统时间
cal 显示日历
# 📥 软件管理 (Ubuntu/Debian)
apt update 更新软件源
apt upgrade 升级已安装软件
apt install pkg 安装软件
apt remove pkg 卸载软件
apt purge pkg 卸载并清除配置
apt search pkg 搜索软件包
apt show pkg 查看软件包信息
# 🔄 重定向与管道
echo "hello" > file 覆盖写入
echo "world" >> file 追加写入
cat file | grep "abc" 管道:查找文件中的 abc







