如果是 Rocky Linux & RHEL:
/var/log/cron
如果是 openSUSE & SLES:
/var/spool/mail/<user>
如果是 Rocky Linux & RHEL:
/var/log/cron
如果是 openSUSE & SLES:
/var/spool/mail/<user>
# /usr/bin/last -xF | egrep "reboot|shutdown|runlevel|system"
Linux 的 kernel 会把开机日子存储在 ring buffer 和 /var/log/message 中,其中 ring buffer 里的开机日志可以使用 dmesg 来显示,如果开机时的提示信息来不及阅读的话,可以通过 dmesg 命令来显示
1) -c 显示 ring buffer 的日志后清空 ring buffer
2) -n 显示日志的层级
3) -cn 显示 ring buffer 的日志后清空 ring buffer,同时显示日志的层级
4) -s 设置缓冲区的大小,默认为 8196 与 ring buffer 的大小一样
# dmesg | less
# dmesg -cn
# dmesg | egrep -i "fail|warn|error"
在 SELinuxProject 的官网上下载 SELinux 策略 UseRefpolicy:
https://github.com/SELinuxProject/refpolicy/wiki/UseRefpolicy
1) 如果使用此文的方法将 openSUSE & SLE 的 SELinux 设置为 Enforcing 则系统将无法设置 IP 地址
2) 如果使用此文的方法开启了 SELinux 并且将所有的布尔(boolean)值开启,则系统将无法关机,开启所有布尔值的方法:# for i in semanage boolean -l | awk '{print $1}'
; do echo $i;setsebool -P $i 1; done
# zypper in libselinux1 libsemanage1 libsepol-devel libsepol1 libselinux-devel mcstrans libselinux1-32bit policycoreutils checkpolicy libsemanage-devel setools-tcl setools-libs setools-java setools-devel setools-console selinux-tools python3-policycoreutils python3-selinux python3-semanage python3-setools restorecond
# tar -xvf refpolicy-2.20210203.tar.bz2
(补充:这里以解压 refpolicy-2.20210203.tar.bz2 压缩包为例)
# mv refpolicy /etc/selinux/
# cd /etc/selinux/refpolicy/
# cat INSTALL
# make conf
# make policy
# make install
# make load
# vim /etc/selinux/config
创建以下内容:
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=permissive
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=refpolicy
# vim /etc/default/grub
在这一行里:
GRUB_CMDLINE_LINUX_DEFAULT="......"
添加以下内容:
GRUB_CMDLINE_LINUX_DEFAULT="...... security=selinux selinux=1 enforcing=0"
# grub2-mkconfig -o /boot/grub2/grub.cfg
# restorecon -Rp /
# reboot
https://documentation.suse.com/sles/15-SP2/html/SLES-all/cha-selinux.html
1) Disabled:完全关闭 SELinux
2) Permissive:即使违反了策略也依旧可以执行,但是违反策略的记录会被记录在日志中
3) Enforcing:如果违反了策略就不能之行
# vim /etc/selinux/config
将以下内容:
......
SELINUX=......
......
修改为:
......
SELINUX=disabled
......
# reboot
# getenforce
Disabled
# vim /etc/selinux/config
将以下内容:
......
SELINUX=......
......
修改为:
......
SELINUX=permissive
......
# reboot
# getenforce
Permissive
# vim /etc/selinux/config
将以下内容:
......
SELINUX=......
......
修改为:
......
SELINUX=enforcing
......
# reboot
# getenforce
Enforcing
# setenfoce 0
(
注意:
1) 系统重启后失效
2) 只能从 Enforcing 状态切换到 Permissive 状态
)
# getenforce
Permissive
# setenfoce 1
(
注意:
1) 系统重启后失效
2) 只能从 Permissive 状态切换到 Enforcing 状态
)
# getenforce
Enforcing