CentOS 7常见的基础命令和配置

前端之家收集整理的这篇文章主要介绍了CentOS 7常见的基础命令和配置前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。


@H_403_2@

管理服务@H_403_2@


@H_403_2@

命令格式:systemctl COMMAND name.service
注意:以下name.service表示某个具体服务@H_403_2@

启动:service name start  ==> systemctl start name.service
停止:service name stop ==> systemctl stop name.service
重启:service name restart ==> systemctl restart name.service
状态:service name status ==> systemctl status name.service
条件式重启:已启动才重启,否则不做操作: service name cond restart ==> systemctl try-restart name.service
重载或重启服务:先加载,再启动: systemctl reload-or-restart name.service
重载或条件式重启服务:systemctl reload-or-try-restart name.service
禁止自动和手动启动:systemctl mask name.service
取消禁止:systemctl unmask name.service


@H_403_2@

服务查看@H_403_2@

##查看 某服务当前激活与否的状态: systemctl is-active name.service
##查看所有已经激活的服务: systemctl list-units --type|-t service
##查看所有服务: systemctl list-units --type service -a


@H_403_2@

服务状态@H_403_2@

systemctl list-units --type service --all 显示状态
loaded:Unit 配置文件已处理
active(running): 一次或多次持续处理的运行
active(exited): 成功完成一次性的配置
active(waiting): 运行中,等待一个事件
inactive: 不运行
enabled: 开机启动
disabled: 开机不启动
static:开机不启动,但可被另一个启用的服务激活


@H_403_2@

杀掉进程@H_403_2@

systemctlkill进程名


@H_403_2@

chkconfig命令的对应关系@H_403_2@

设定某服务开机自启:
chkconfig name on ==> systemctl enable name.service
设定某服务开机禁止启动:
chkconfig name off ==> systemctl disable name.service
查看所有服务的开机自启状态:
chkconfig --list ==> systemctl list-unit-files --type service


@H_403_2@

用来列出该服务在哪些运行级别下启用和 禁用@H_403_2@

chkconfig sshd �Clist ==> ls /etc/systemd/system/*.wants/sshd.service
[root@localhost ~]# ls /etc/systemd/system/*.wants/sshd.service
/etc/systemd/system/multi-user.target.wants/sshd.service


@H_403_2@

查看服务是否开机自启:@H_403_2@

systemctl is-enabled name.service
[root@localhost ~]# systemctl is-enabled sshd.service
enabled


@H_403_2@

查看服务的依赖关系:@H_403_2@

systemctllist-dependenciesname.service


@H_403_2@

运行级别
@H_403_2@


unit 配置文件:.target@H_403_2@

@H_403_2@

ls /usr/lib/systemd/system/*.target
systemctl list-unit-files --type target --all //查看级别


@H_403_2@

查看依赖性:@H_403_2@

systemctllist-dependenciesgraphical.target//查看级别的依赖性
原文链接:https://www.f2er.com/centos/375540.html

猜你在找的CentOS相关文章