linux笔记之systemctl命令

it2022-05-09  59

通过systemctl来管理单一服务的启动、开机启动和状态查看。 systemctl [command] [unit] command主要有: start:立刻启动unit stop:立刻关闭unit restart:立即重启 reload:不关闭unit下重新加载配置文件 enable:开机启动 disable:开机不启动 is-active:当前有没有在运行 is-enable:开机时是否默认启动unit

特别注意:当某项服务存在依赖时,仅仅关闭一项服务而没有关闭其他的服务的话是没用的,因为当其依赖的其他服务使用时,会唤醒该服务。 可以使用(mask)强迫服务注销,该命令会将某服务的依赖服务一并关闭: 如下:systemctl mask 【服务】 //使用unmask用来取消注销操作

使用systemctl 查看系统的所有服务 systemctl [command] [unit] command: list-units :显示目前启动的unit list-unit-files:由/usr/lib/systemd/system/内的文件,将所有的文件列表说明 通过systemctl来管理不同的操作环境 systemctl [command] [unit.target] command: get-default:取得目前的target set-default:设置后面的unit.target为默认操作模式 isolate:切换模式 例如: systemctl isolate graphical.target 切换到图形界面 systemctl isolate multi-user.target 切换到纯命令模式

最新回复(0)