1. start法则
start法则 | |
s | 什么情况 |
t | 什么目标 |
a | 什么步骤 |
r | 什么结果 |
2. systemctl管理服务
2.1. 开启服务
# 开启sshd服务
systemctl start sshd
# 设置sshd服务下次开机启动
systemctl enable sshd
# 开启sshd服务并设置下次开机自启动
systemctl enable sshd --now
2.2. 关闭服务
# 关闭firewalld服务
systemctl stop firewalld
# 设置firewalld服务下次开启不启动
systemctl disable firewalld
# 关闭firewalld服务并设置下次开机不启动
systemctl disable firewalld --now
2.3. 查看服务状态
# 查看服务状态
systemctl status sshd
# 查看服务是否运行
systemctl is-active sshd
# 查看服务是否开启自启动
systemctl is-enabled sshd
2.4. 启动服务失败
2.4.1. ssh服务启动失败
[root@ky201 ~]# systemctl restart sshd
Job for sshd.service failed because the control process exited with error code.
See "systemctl status sshd.service" and "journalctl -xe" for details.
2.4.2. 解决
1.systemctl status sshd 查看服务状态
2.journalctl -xe 查看详细的服务状态信息
journalctl -xe -u ssh 查看详细的服务状态信息,指定ssh服务
3.查看日志,如果没有特定日志文件,查看/var/log/message
3. localectl修改字符集
3.1. 永久修改
[root@ky201 ~]# localectl
System Locale: LANG=zh_CN.UTF-8
VC Keymap: cn
X11 Layout: cn
zh_CN:中文
en_US:英文
[root@ky201 ~]# localectl set-locale LANG=en_US.UTF-8
3.2. 临时修改
export LANG=en_US.UTF-8
4. 面试题:linux运行级别
linux运行级别 | |
0 | poweroff关机 |
1 | rescue救援模式,单用户模式 |
2 | multi-user多用户级别,命令行模式,文本模式 |
3 | multi-user多用户级别,命令行模式,文本模式 |
4 | multi-user多用户级别,命令行模式,文本模式 |
5 | graphical图形化模式,桌面模式,X11(几乎不用) |
6 | reboot重启 |
4.1. 修改运行级别
# 查看运行级别
systemctl get-default
# 修改运行级别
systemctl set-default
5. 面试题:linux启动流程
6. 总结
- systemctl服务管理
- localectl修改语言
- 面试题