Linux系统100条命令:关于Ubuntu和 CentOS 7 相同功能的不同的终端操作命令

2023-09-21 12:45:09

在这里插入图片描述

  1. 安装软件包:

Ubuntu:apt-get install package_name
CentOS 7:yum install package_name

  1. 更新软件包列表:

Ubuntu:apt-get update
CentOS 7:yum update

  1. 卸载软件包:

Ubuntu:apt-get remove package_name
CentOS 7:yum remove package_name

  1. 查找文件:

Ubuntu:find /path/to/search -name “filename”
CentOS 7:find /path/to/search -name “filename”

  1. 显示系统信息:

Ubuntu:lsb_release -a
CentOS 7:cat /etc/centos-release

  1. 查看网络接口信息:

Ubuntu:ifconfig
CentOS 7:ip addr

  1. 启动服务:

Ubuntu:systemctl start service_name
CentOS 7:systemctl start service_name

  1. 停止服务:

Ubuntu:systemctl stop service_name
CentOS 7:systemctl stop service_name

  1. 重新启动服务:

Ubuntu:systemctl restart service_name
CentOS 7:systemctl restart service_name

  1. 查看服务状态:

Ubuntu:systemctl status service_name
CentOS 7:systemctl status service_name

  1. 启用服务(开机自启动):

Ubuntu:systemctl enable service_name
CentOS 7:systemctl enable service_name

  1. 禁用服务(开机不自启动):

Ubuntu:systemctl disable service_name
CentOS 7:systemctl disable service_name

  1. 防火墙规则操作:

Ubuntu:ufw allow port_number
CentOS 7:firewall-cmd --zone=public --add-port=port_number/tcp --permanent

  1. 用户管理 - 创建用户:

Ubuntu:adduser username
CentOS 7:useradd username

  1. 用户管理 - 修改密码:

Ubuntu:passwd username
CentOS 7:passwd username

  1. 用户管理 - 删除用户:

Ubuntu:deluser username
CentOS 7:userdel username

  1. 用户管理 - 用户组管理:

Ubuntu:addgroup groupname
CentOS 7:groupadd groupname

  1. 用户管理 - 用户属性修改:

Ubuntu:usermod -aG groupname username
CentOS 7:usermod -aG groupname username

  1. 显示磁盘空间使用情况:

Ubuntu:df -h
CentOS 7:df -h

  1. 显示内存使用情况:

Ubuntu:free -m
CentOS 7:free -m

  1. 显示系统日历:

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

  1. 显示进程信息:

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

  1. 查看系统运行的进程和资源使用情况:

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

  1. 查看系统的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

更多推荐

【CNN-FPGA开源项目解析】01--floatMult16模块

文章目录(基础)半精度浮点数的表示和乘运算16位半精度浮点数浮点数的乘运算floatMult16完整代码floatMult16代码逐步解析符号位sign判断指数exponent计算尾数fraction计算尾数fraction的标准化和舍位整合为最后的16位浮点数结果[sign,exponent,fraction]其他变

MySQL数据库

1、数据库的基本概念1.1数据·描述事物的符号记录·包括数字、文字、图形、图像、声音、档案记录等·以“记录”形式按统一的格式进行存储1.2表·将不同的记录组织在一起的·用来存储具体数据1.3数据库​​·表的集合,是存储数据的仓库·以一定的组织方式存储的相互有关的数据集合1.4数据库管理系统·是实现对数据库资源有效组织、

C++面试/笔试准备,资料汇总

文章目录后端太卷,建议往嵌入式,qt,测试,音视频,C++一些细分领域投简历。有任何疑问评论区聊,我看到了回复C++面试/笔试准备,资料汇总自我介绍项目实习尽可能有1.编程语言:一.熟悉C++语言,熟悉std::string的底层实现。string的底层实现(写时复制技术)1、引用&指针野指针2、C++中的继承,多态,

浅谈低压电力电容器常见故障分析及预防措施

安科瑞华楠【摘要】为了可以有效实现提高电力电容器故障解决效率,就需要针对其故障诊断技术展开研究,而状态量监测作为提高故障诊断技术效率与质量重要因素,其对电力电容器故障诊断工作而言,有着重要影响意义。基于此,本文首先将会针对传统电力电容器故障诊断工作展开分析,而后针对基于状态量监测电力电容器故障诊断技术展开研究,进而制定

深入了解Vue.js框架:构建现代化的用户界面

目录一.Vue前言介绍二.Vue.js框架的核心功能与特性三.MVVM的介绍四.Vue的生命周期五.库与框架的区别1.库(Library):2.框架(Framework):六.Vue常用指令演示1.v-model2.v-on:click(简写:@click)本篇博客将带你深入了解Vue.js框架的核心概念和强大功能互关

ClickHouse进阶(十七):clickhouse优化-写出查询优化

进入正文前,感谢宝子们订阅专题、点赞、评论、收藏!关注IT贫道,获取高质量博客内容!🏡个人主页:含各种IT体系技术,IT贫道_大数据OLAP体系技术栈,ApacheDoris,Kerberos安全认证-CSDN博客📌订阅:拥抱独家专题,你的订阅将点燃我的创作热情!👍点赞:赞同优秀创作,你的点赞是对我创作最大的认可

【C++/Python】Windows用Swig实现C++调用Python(史上最简单详细,80岁看了都会操作)

👉博__主👈:米码收割机👉技__能👈:C++/Python语言👉公众号👈:测试开发自动化【获取源码+商业合作】👉荣__誉👈:阿里云博客专家博主、51CTO技术博主👉专__注👈:专注主流机器人、人工智能等相关领域的开发、测试技术。#【C++/Python】Swig实现C++调用Python(史上最简单

Investigating Answerability of LLMs for Long-Form Question Answering

本文是LLM系列的文章,针对《InvestigatingAnswerabilityofLLMsforLong-FormQuestionAnswering》的翻译。LLM在长形式问答中的可回答性研究摘要1引言2相关工作3提出的评估方法4结果与分析5结论6局限性摘要随着我们进入LLM的新时代,了解它们的能力、局限性和差异变

性能测试 —— Jmeter 常用三种定时器

1、同步定时器位置:HTTP请求->定时器->SynchronizingTimer当需要进行大量用户的并发测试时,为了让用户能真正的同时执行,添加同步定时器,用户阻塞线程,知道线程数达到预先配置的数值,才开始执行取样器的操作测试绝对并发,比如秒杀,抢购等场景,结果要用聚合报告查看简单案例:模拟50个用户同时访问百度线程

zookeeper

目录1、zookeeper理论1.1、简介1.2、Zookeeper工作机制.1.3、Zookeeper特点**1.5、Zookeeper应用场景1.6、Zookeeper选举机制****1.6.1、第一次启动选举机制1.6.2、非第一次启动选举机制1.6.3、选举Leader规则:2、kafka2.1、概述2.2、为

Flutter的oktoast插件详解

文章目录简介详细介绍安装和导入导入在MaterialApp外面套一层OKToast组件为什么是包住MaterialApp?显示Toast消息:高级使用Toast位置Toast持续时间自定义Toast样式高级用法使用场景提示消息表单验证操作反馈网络请求状态调试信息小结总结简介oktoast是一个Flutter库,它提供了

热文推荐