Linux 软件包|服务管理

发布于:2025-05-14 ⋅ 阅读:(15) ⋅ 点赞:(0)

rpm

指令 备注
rpm -qa 查看已安装软件,可以结合grep过滤查找
rpm -e firefox 卸载firefox
rpm -ivh firefox-115.12.0-1.el7.centos.i686.rpm 安装gcc(只能离线安装)

yum

能够从指定的服务器自动下载 RPM 包并且安装

指令 备注
yum list 列出所有可安裝的软件清单,可以结合grep过滤查找
yum install firefox 安装firefox
yum update firefox 更新firefox
yum remove firefox 移除firefox
yum check-update firefox 检查更新
yum deplist firefox 展示依赖关系

推荐安装 yum-utils 实现rpm包离线下载

CentOS 6及更早版本

调用/etc/init.d/目录下的脚本管理服务

CentOS 7+

管理.service单元文件(位于/usr/lib/systemd/system/)

操作 service 命令 systemctl 命令
启动服务 service <服务名> start systemctl start <服务名>.service
停止服务 service <服务名> stop systemctl stop <服务名>.service
重启服务 service <服务名> restart systemctl restart <服务名>.service
查看状态 service <服务名> status systemctl status <服务名>.service
开机自启 chkconfig <服务名> on systemctl enable <服务名>.service
禁用开机自启 chkconfig <服务名> off systemctl disable <服务名>.service
查看所有服务 chkconfig --list systemctl list-units --type=service

sudo

sudo命令用来以其他身份来执行命令,预设的身份为root。在/etc/sudoers中设置了可执行sudo指令的用户。

指令 备注
cat /etc/sudoers 查看可执行sudo指令的用户

建议在/etc/sudoers.d里添加自定义文件

ps

用于报告当前系统的进程状态

指令 备注
ps -ef 可以结合grep过滤查找

kill

用于终止正在运行的进程

指令 备注
kill pid 正常结束进程 默认信号:15
kill -9 pid 立即结束进程

top

实时动态地查看系统的整体运行情况


网站公告

今日签到

点亮在社区的每一天
去签到