
- 安装软件包:
 
Ubuntu:apt-get install package_name
 CentOS 7:yum install package_name
- 更新软件包列表:
 
Ubuntu:apt-get update
 CentOS 7:yum update
- 卸载软件包:
 
Ubuntu:apt-get remove package_name
 CentOS 7:yum remove package_name
- 查找文件:
 
Ubuntu:find /path/to/search -name “filename”
 CentOS 7:find /path/to/search -name “filename”
- 显示系统信息:
 
Ubuntu:lsb_release -a
 CentOS 7:cat /etc/centos-release
- 查看网络接口信息:
 
Ubuntu:ifconfig
 CentOS 7:ip addr
- 启动服务:
 
Ubuntu:systemctl start service_name
 CentOS 7:systemctl start service_name
- 停止服务:
 
Ubuntu:systemctl stop service_name
 CentOS 7:systemctl stop service_name
- 重新启动服务:
 
Ubuntu:systemctl restart service_name
 CentOS 7:systemctl restart service_name
- 查看服务状态:
 
Ubuntu:systemctl status service_name
 CentOS 7:systemctl status service_name
- 启用服务(开机自启动):
 
Ubuntu:systemctl enable service_name
 CentOS 7:systemctl enable service_name
- 禁用服务(开机不自启动):
 
Ubuntu:systemctl disable service_name
 CentOS 7:systemctl disable service_name
- 防火墙规则操作:
 
Ubuntu:ufw allow port_number
 CentOS 7:firewall-cmd --zone=public --add-port=port_number/tcp --permanent
- 用户管理 - 创建用户:
 
Ubuntu:adduser username
 CentOS 7:useradd username
- 用户管理 - 修改密码:
 
Ubuntu:passwd username
 CentOS 7:passwd username
- 用户管理 - 删除用户:
 
Ubuntu:deluser username
 CentOS 7:userdel username
- 用户管理 - 用户组管理:
 
Ubuntu:addgroup groupname
 CentOS 7:groupadd groupname
- 用户管理 - 用户属性修改:
 
Ubuntu:usermod -aG groupname username
 CentOS 7:usermod -aG groupname username
- 显示磁盘空间使用情况:
 
Ubuntu:df -h
 CentOS 7:df -h
- 显示内存使用情况:
 
Ubuntu:free -m
 CentOS 7:free -m
- 显示系统日历:
 
Ubuntu:cal
 CentOS 7:cal
 22. 查看系统运行时间和平均负载:
Ubuntu:uptime
 CentOS 7:uptime
 23. 显示当前登录用户列表:
Ubuntu:who
 CentOS 7:who
 24. 显示系统启动日志:
Ubuntu:journalctl -b
 CentOS 7:journalctl -b
 25. 查看系统日志:
Ubuntu:less /var/log/syslog
 CentOS 7:less /var/log/messages
 26. 显示系统主机名:
Ubuntu:hostname
 CentOS 7:hostname
 27. 显示文件和目录的权限:
Ubuntu:ls -l file_or_directory
 CentOS 7:ls -l file_or_directory
 28. 创建目录:
Ubuntu:mkdir directory_name
 CentOS 7:mkdir directory_name
 29. 删除目录:
Ubuntu:rmdir directory_name
 CentOS 7:rmdir directory_name
 30. 创建空文件:
Ubuntu:touch filename.txt
 CentOS 7:touch filename.txt
 31. 复制文件或目录:
Ubuntu:cp source destination
 CentOS 7:cp source destination
 32. 移动文件或目录:
Ubuntu:mv source destination
 CentOS 7:mv source destination
 33. 删除文件或目录:
Ubuntu:rm file_or_directory
 CentOS 7:rm file_or_directory
 34. 查看文件内容:
Ubuntu:cat filename.txt
 CentOS 7:cat filename.txt
 35. 逐页查看文件内容:
Ubuntu:less filename.txt
 CentOS 7:less filename.txt
 36. 查看文件的前几行:
Ubuntu:head filename.txt
 CentOS 7:head filename.txt
 37. 查看文件的最后几行:
Ubuntu:tail filename.txt
 CentOS 7:tail filename.txt
 38. 在文件中搜索文本:
Ubuntu:grep “pattern” filename.txt
 CentOS 7:grep “pattern” filename.txt
 39. 测试与远程主机的网络连接:
Ubuntu:ping hostname_or_ip
 CentOS 7:ping hostname_or_ip
 40. 显示网络接口配置信息:
Ubuntu:ifconfig
 CentOS 7:ip addr
- 显示进程信息:
 
Ubuntu:ps aux
 CentOS 7:ps aux
 42. 终止进程:
Ubuntu:kill process_id
 CentOS 7:kill process_id
 43. 显示当前用户信息:
Ubuntu:id
 CentOS 7:id
 44. 创建软链接:
Ubuntu:ln -s source_file link_name
 CentOS 7:ln -s source_file link_name
 45. 显示系统内核版本:
Ubuntu:uname -r
 CentOS 7:uname -r
 46. 显示可用磁盘空间:
Ubuntu:df -h
 CentOS 7:df -h
 47. 显示可用内存和交换空间:
Ubuntu:free -m
 CentOS 7:free -m
 48. 显示系统进程的内存使用情况:
Ubuntu:ps aux --sort -%mem
 CentOS 7:ps aux --sort -%mem
 49. 显示系统进程的CPU使用情况:
Ubuntu:ps aux --sort -%cpu
 CentOS 7:ps aux --sort -%cpu
 50. 显示系统当前时间:
Ubuntu:date
 CentOS 7:date
 51. 显示日历:
Ubuntu:cal
 CentOS 7:cal
 52. 显示系统的启动时间:
Ubuntu:systemctl show -p ActiveEnterTimestamp --value
 CentOS 7:systemd-analyze
 53. 显示系统中的硬件信息:
Ubuntu:lshw
 CentOS 7:lshw
 54. 显示可用网络接口:
Ubuntu:ip link show
 CentOS 7:ip link show
 55. 显示系统中的PCI设备:
Ubuntu:lspci
 CentOS 7:lspci
 56. 显示系统中的USB设备:
Ubuntu:lsusb
 CentOS 7:lsusb
 57. 显示系统中的SCSI设备:
Ubuntu:lsscsi
 CentOS 7:lsscsi
 58. 显示系统中的CPU信息:
Ubuntu:lscpu
 CentOS 7:lscpu
 59. 显示系统中的内存信息:
Ubuntu:lsmem
 CentOS 7:lsmem
 60. 显示系统中的文件系统信息:
Ubuntu:df -T
 CentOS 7:df -T
- 查看系统运行的进程和资源使用情况:
 
Ubuntu:htop
 CentOS 7:top
 62. 定时执行任务(cron):
Ubuntu:crontab -e
 CentOS 7:crontab -e
 63. 显示系统主机名:
Ubuntu:hostname
 CentOS 7:hostname
 64. 查看系统中已安装的软件包:
Ubuntu:dpkg --list
 CentOS 7:rpm -qa
 65. 显示系统环境变量:
Ubuntu:printenv
 CentOS 7:env
 66. 显示系统日志文件:
Ubuntu:cat /var/log/syslog
 CentOS 7:cat /var/log/messages
 67. 显示网络路由表:
Ubuntu:ip route
 CentOS 7:route -n
 68. 显示系统硬盘分区信息:
Ubuntu:lsblk
 CentOS 7:fdisk -l
 69. 创建压缩文件(tar):
Ubuntu:tar -czvf archive.tar.gz /path/to/directory
 CentOS 7:tar -czvf archive.tar.gz /path/to/directory
 70. 解压缩文件(tar):
Ubuntu:tar -xzvf archive.tar.gz
 CentOS 7:tar -xzvf archive.tar.gz
 71. 安装软件包(snap):
Ubuntu:snap install package_name
 CentOS 7:Snap 不是 CentOS 7 默认支持的包管理器。
 72. 切换用户:
Ubuntu:su username
 CentOS 7:su username
 73. 切换用户并保留环境变量:
Ubuntu:su - username
 CentOS 7:su - username
 74. 显示系统内核模块:
Ubuntu:lsmod
 CentOS 7:lsmod
 75. 列出已安装的文件包及其信息:
Ubuntu:dpkg -l
 CentOS 7:rpm -qa
 76. 设置静态IP地址(命令行方式):
Ubuntu:编辑 /etc/network/interfaces 文件
 CentOS 7:编辑 /etc/sysconfig/network-scripts/ifcfg-eth0 文件
 77. 启用和禁用网络接口:
Ubuntu:ifconfig interface_name up 或 ifconfig interface_name down
 CentOS 7:ip link set interface_name up 或 ip link set interface_name down
 78. 显示用户登陆历史记录:
Ubuntu:last
 CentOS 7:last
 79. 显示系统开机时间:
Ubuntu:uptime -s
 CentOS 7:uptime -s
 80. 显示系统CPU信息(详细):
Ubuntu:lscpu
 CentOS 7:lscpu
- 查看系统的DNS配置:
 
Ubuntu:cat /etc/resolv.conf
 CentOS 7:cat /etc/resolv.conf
 82. 显示系统时间同步状态:
Ubuntu:timedatectl status
 CentOS 7:timedatectl status
 83. 显示系统开机启动服务:
Ubuntu:systemctl list-unit-files | grep enabled
 CentOS 7:systemctl list-unit-files | grep enabled
 84. 显示系统环境变量的值:
Ubuntu:echo $VAR_NAME
 CentOS 7:echo $VAR_NAME
 85. 显示当前用户的家目录:
Ubuntu:echo $HOME
 CentOS 7:echo $HOME
 86. 显示系统启动的进程:
Ubuntu:systemctl list-units --type=service
 CentOS 7:systemctl list-units --type=service
 87. 显示已安装的内核包列表:
Ubuntu:dpkg -l | grep linux-image
 CentOS 7:rpm -qa | grep kernel
 88. 显示系统的默认编辑器:
Ubuntu:update-alternatives --display editor
 CentOS 7:alternatives --display editor
 89. 显示当前登录用户的组:
Ubuntu:groups
 CentOS 7:groups
 90. 显示系统启动时运行的脚本(系统d服务):
Ubuntu:systemctl list-dependencies multi-user.target
 CentOS 7:systemctl list-dependencies multi-user.target
 91. 显示文件的inode号:
Ubuntu:ls -i filename
 CentOS 7:ls -i filename
 92. 显示系统开机启动的级别:
Ubuntu:runlevel
 CentOS 7:systemctl get-default
 93. 显示系统内核参数:
Ubuntu:sysctl -a
 CentOS 7:sysctl -a
 94. 显示已加载的内核模块:
Ubuntu:lsmod
 CentOS 7:lsmod
 95. 显示用户账户的详细信息:
Ubuntu:finger username
 CentOS 7:finger username
 96. 显示系统的电源状态:
Ubuntu:upower -i /org/freedesktop/UPower/devices/battery_BAT0
 CentOS 7:cat /sys/class/power_supply/BAT0/status
 97. 显示系统的默认编辑器:
Ubuntu:update-alternatives --config editor
 CentOS 7:alternatives --config editor
 98. 显示系统中的网络连接:
Ubuntu:ss -tuln
 CentOS 7:netstat -tuln
 99. 显示系统中的CPU负载:
Ubuntu:cat /proc/loadavg
 CentOS 7:cat /proc/loadavg
 100. 显示系统的启动日志:
Ubuntu:journalctl -b
 CentOS 7:journalctl -b



















