Linux基础入门教程11课-systemctl工具使用方法

systemd是一个更高效的系统&服务管理器,其相关特性如下:

  • 开机服务并行启动,各系统服务间的精确依赖
  • 配置目录:/etc/systemd/system/
  • 服务目录:/lib/systemd/system/

systemctl是systemd的管理工具,将相关资源组织为unit配置单元进行管理。

不同的unit决定了一组相关的启动任务,service和target是最常用的配置单元:

  • service:后台独立服务
  • target:一套配置单元的组合,类似于传统“运行级别”

重启 httpd、crond、bluetooth 服务,查看状态

1)重启系统服务httpd、crond、bluetooth

  1. [root@localhost~]# systemctl restart httpd crond bluetooth

2)查看上述服务的状态

  1. [root@localhost~]# systemctl status httpd crond bluetooth
  2. * httpd.service - The Apache HTTP Server
  3. Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
  4. Active: active (running) since Fri 2017-01-06 18:18:20 CST; 18s ago
  5. .. ..
  6. * crond.service - Command Scheduler
  7. Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)
  8. Active: active (running) since Fri 2017-01-06 18:18:19 CST; 19s ago
  9. .. ..
  10. * bluetooth.service - Bluetooth service
  11. Loaded: loaded (/usr/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
  12. Active: active (running) since Fri 2017-01-06 18:18:19 CST; 19s ago
  13. .. ..

步骤二:禁止 bluetooth 服务开机自启,并停用此服务

1)停用bluetooth服务

  1. [root@localhost~]# systemctl stop bluetooth

2)禁止bluetooth服务开机自启

  1. [root@localhost~]# systemctl disable bluetooth
  2. Removed symlink /etc/systemd/system/dbus-org.bluez.service.
  3. Removed symlink /etc/systemd/system/bluetooth.target.wants/bluetooth.service.
  4. [root@localhost~]# systemctl is-enabled Bluetooth             //检查结果
  5. disabled

步骤三:设置默认级别为 multi-user.target 并确认

1)查看默认运行级别

  1. [root@localhost~]# systemctl get-default
  2. graphical.target

2)将默认运行级别设置为multi-user.target

  1. [root@localhost~]# systemctl set-default multi-user.target
  2. Removed symlink /etc/systemd/system/default.target.
  3. Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/multi-user.target.

3)确认配置结果

  1. [root@localhost~]# systemctl get-default
  2. multi-user.target

根据此处的设置,重启此虚拟机后图形桌面将不再可用。

 

 

您可以选择一种方式赞助本站

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: