Linux systemctl
systemctl 命令,主要有两个功能:
- 控制 systemd 系统
- 管理系统上运行的服务
systemctl 融合了 service 和 chkconfig 的功能于一体,可以通过它启用/禁用服务,不带任何参数执行 systemctl 命令会列出所有已启动的 unit。unit 有如下几种类型:
- service
- socket
- device
- mount
- automount
- swap
- target
- timer
语法:
systemctl [OPTIONS…] COMMAND [NAME…]
COMMAND:
- start:立刻启动后面接的 unit
- stop:立刻关闭后面接的 unit
- restart:立刻重新启动后面接的unit
- reload:不关闭 unit 的情况下,重新载入配置文件,让设置生效
- enable:设置下次开机时,后面接的 unit 会被启动
- disable:设置下次开机时,后面接的 unit 不会被启动
- status:目前后面接的这个 unit 的状态
- list-unit-files:列出所有已经安装的服务及状态
UNIT FILE STATE
proc-sys-fs-binfmt_misc.automount static
dev-hugepages.mount static
dev-mqueue.mount static
proc-sys-fs-binfmt_misc.mount static
sys-fs-fuse-connections.mount static
sys-kernel-config.mount static
sys-kernel-debug.mount static
tmp.mount disabled
brandbot.path disabled
systemd-ask-password-console.path static
systemd-ask-password-plymouth.path static
systemd-ask-password-wall.path static
session-1.scope static
aliyun.service disabled
arp-ethers.service disabled
atd.service enabled
auditd.service enabled
autovt@.service enabled
blk-availability.service disabled
注:static 指对应的 Unit 文件中没有定义[Install]区域,因此无法配置为开机启动服务
查看 Linux 系统版本
- uname -a (查看操作系统内核信息)
Linux lslxy1021 3.10.0-514.26.2.el7.x86_64 #1 SMP Tue Jul 4 15:04:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
- cat /etc/redhat-release (查看发行版本信息)
CentOS Linux release 7.3.1611 (Core)
- lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.3.1611 (Core)
Release: 7.3.1611
Codename: Core
[root@lslxy1021 ~]# lsb_release
LSB Version: :core-4.1-amd64:core-4.1-noarch
- cat /proc/cpuinfo (查看 cpu 信息,包括型号、主频、核数)