Linux System Commands Cheat Sheet
This article provides a comprehensive reference of essential Linux system commands covering system information, date and time management, shutdown/reboot, file and directory operations, searching, mounting, disk usage, user and group management, permissions, special attributes, compression, package handling, network utilities, and backup techniques, all presented with concise examples for quick learning.
This guide lists common Linux commands and their typical usage, organized by functional categories for quick reference.
查看Linux系统信息
arch #显示机器的处理器架构(1)
uname -m #显示机器的处理器架构(2)
uname -r #显示正在使用的内核版本
... (additional commands omitted for brevity)date 显示系统日期
cal 2007 #显示2007年的日历表
date 041217002007.00 #设置日期和时间 - 月日时分年.秒
clock -w #将时间修改保存到 BIOS关机(关机、重启、登出 )
shutdown -h now #关闭系统(1)
init 0 #关闭系统(2)
shutdown -r now #重启系统
reboot #重启系统(2)
logout #注销文件和目录
cd /home #进入 '/home' 目录
cd .. #返回上一级目录
pwd #显示工作路径
ls -l #查看目录中的文件详细信息
mkdir dir1 #创建目录 dir1
rm -rf dir1 #删除目录及其内容
cp file1 file2 #复制文件
ln -s file1 link1 #创建软链接文件搜索
find / -name file1 #从根文件系统搜索文件
find /home/user1 -name *.bin #搜索 .bin 结尾的文件
locate *.ps #寻找以 .ps 结尾的文件(需先 updatedb)挂载文件系统
mount /dev/hda2 /mnt/hda2 #挂载分区
umount /dev/hda2 #卸载分区
mount -o loop file.iso /mnt/cdrom #挂载 ISO 镜像磁盘空间相关
df -h #显示已挂载分区列表
du -sh dir1 #估算目录使用的磁盘空间
rpm -q -a --qf '%10{SIZE}t%{NAME}n' | sort -k1,1n #按大小显示已安装的 rpm 包用户和群组
groupadd group_name #创建用户组
groupdel group_name #删除用户组
useradd -c "Name Surname" -g admin -d /home/user1 -s /bin/bash user1 #创建用户并指定组
passwd user1 #修改用户口令文件权限
chmod ugo+rwx directory1 #设置所有人、群组、其他人读写执行权限
chown user1 file1 #改变文件所有者
chmod u+s /bin/file1 #设置 SUID 位文件的特殊属性
chattr +i file1 #设置不可变属性
lsattr #显示特殊属性打包和压缩文件
tar -cvf archive.tar file1 #创建 tar 包
tar -czvf archive.tar.gz dir1 #创建 gzip 压缩包
zip file1.zip file1 #创建 zip 包RPM 包(Fedora, Redhat 及类似系统)
rpm -ivh package.rpm #安装 rpm 包
rpm -qa #列出已安装的 rpm 包YUM(Fedora, RedHat 及类似系统)
yum install package_name #下载并安装 rpm 包
yum update #更新系统中所有已安装的 rpm 包DEB 包 (Debian, Ubuntu 及类似系统)
dpkg -i package.deb #安装/更新 deb 包
dpkg -l #列出已安装的 deb 包APT 软件工具 (Debian, Ubuntu 及类似系统)
apt-get install package_name #安装/更新 deb 包
apt-get update #更新软件包列表查看文件内容
cat file1 #正向查看文件内容
less file1 #支持前后翻页查看文件内容文本处理
grep Aug /var/log/messages #在日志中查找关键词
sed 's/string1/string2/g' file.txt #替换文本内容
awk 'NR%2==1' file.txt #删除偶数行字符设置和文件格式转换
dos2unix filedos.txt fileunix.txt #将 DOS 格式转换为 UNIX
recode ..HTML < page.txt > page.html #转换为 HTML文件系统分析
badblocks -v /dev/hda1 #检查坏磁块
fsck /dev/hda1 #检查并修复文件系统初始化一个文件系统
mkfs /dev/hda1 #创建文件系统
mke2fs -j /dev/hda1 #创建 ext3 文件系统SWAP 文件系统
mkswap /dev/hda3 #创建 swap 文件系统
swapon /dev/hda3 #启用 swap备份
rsync -rogpav --delete /home /tmp #同步目录
dd if=/dev/hda | gzip | ssh user@host 'dd of=hda.gz' #通过 SSH 备份磁盘光盘
mkisofs /dev/cdrom > cd.iso #创建 ISO 镜像
cdrecord -v dev=/dev/cdrom cd.iso #刻录 ISO 镜像网络 - (以太网和 WIFI 无线)
ifconfig eth0 #显示网卡配置
dhclient eth0 #使用 DHCP 获取 IP
route -n #查看路由表
netstat -tupl #显示 TCP/UDP 端口状态Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Selected Java Interview Questions
A professional Java tech channel sharing common knowledge to help developers fill gaps. Follow us!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
