内容一:只显示最近一次开机时间
1.1 使用 top 命令
# top -bn1 | head -1
1.2 使用 who 命令
# who -b
1.3 使用 uptime 命令
# uptime
内容二:显示最近多次开机时间
# last reboot
# top -bn1 | head -1
# who -b
# uptime
# last reboot
# vim /root/12456.sh
创建以下内容:
#!/bin/bash
for i in {1..5}
do
echo $i
done
(补充:这里以创建 /etc/root/for.sh 脚本为例)
# vim /etc/systemd/system/12456.service
创建以下内容:
[Unit]
Description=12345
After=default.target
[Service]
Type=oneshot
ExecStart=/root/12456.sh
[Install]
WantedBy=default.target
(补充:这里以创建 /etc/systemd/system/12456.service 来管理 ExecStart=/root/12456.sh 为例)
# systemctl daemon-reload
# chmod u+x /etc/systemd/system/12456.service
# systemctl start 12456.service
# systemctl stop 12456.service
# systemctl restart 12456.service
# systemctl enable 12456.service
重启系统,进入内核选择界面,此时按下 “e” 键进入内核编辑界面
在 linux 开头的这 1 行将 “ro rhgb quiet” 对应位置的参数修改为 “rd.break enforcing=0”
或者:
这一步也可以换成直接在 linux 开头的这 1 行末尾添加 “rd.break console=tty0”
同时按下 “ctrl” 键和 “x” 键
switch_root:/# mount -o remount,rw /sysroot
switch_root:/# mount | grep sysroot
switch_root:/# chroot /sysroot
sh-4.4# echo 1 | passwd --stdin root
(补充:以上命令的作用是在修改的内核中,将 root 的密码修改为 1,并重启)
sh-4.4# touch /.autorelabel
sh-4.4# sync
sh-4.4# exit
switch_root:/# reboot
服务器系统配置好可用的软件源
# yum -y install cockpit cockpit-dashaboard
(补充:cockpit 是管理单台主机的程序,cockpit-dashaboard 是管理多台主机的程序)
# systemctl enable --now cockpit.socket
使用浏览器登录:https://<server IP address>:9090
同时按下 “ctrl” 键和 “shift” 键和 “+” 键
同时按下 “ctrl” 键和 “-” 键
同时按下 “ctrl” 键和 “shift” 键和 “t” 键
同时按下 “art” 键和 “<sub window number>”
1) 同时按下 “ctrl” 键和 “f2” 键,将当前屏幕切换到图形界面
2) 同时按下 “ctrl” 键和 “f3” 键,将当前屏幕切换到第一个命令行界面
3) 同时按下 “ctrl” 键和 “f4” 键,将当前屏幕切换到第二个命令行界面
4) 同时按下 “ctrl” 键和 “f5” 键,将当前屏幕切换到第三个命令行界面
5) 同时按下 “ctrl” 键和 “f6” 键,将当前屏幕切换到第四个命令行界面