控制台的启动日志消失了?关键在于这些步骤!

linux学习视频

每次我们启动系统的时候,控制台都会显⽰出⼀⼤堆的启动⽇志。

有时候出于保密的考虑,不希望启动⽇志直接显⽰在控制台上。⽐如⼀些安全⼚商提供的基于 Linux 的硬件设备,⾥⾯可能有⼀些内容不希望⽤⼾看到。

这时候,如何让启动⽇志不在控制台显⽰,⽽是保存在⼀个指定的位置,就显得尤为重要。

**!**可以配置 grub2 将⽇志保存到 "/var/log/messages" ⽂件。

下⾯是配置步骤,使得开机的时候,控制台不会显⽰启动⽇志,⽽是将⽇志保存到 "/var/log/messages" 中。

请注意,这个操作需要⼀定的Linux基础,如果你对此还不太熟悉,建议在专业⼈⼠的指导下进⾏。

  1. 编辑 /etc/default/grub ⽂件,并添加以下3个参数

    复制代码
    GRUB_CMDLINE_LINUX_DEFAULT="rd.debug rdudevdebug systemd.log_level=deb
    ugsystemd.log_target=console console=ttyS1,115200n8"
    GRUB_TERMINAL=serial
    GRUB_SERIAL_COMMAND="serial ‒speed=115200 ‒unit=0 ‒word=8 ‒parity=no ‒stop=1"
  2. 重新⽣成 grub2 配置⽂件即可(以下演⽰基于 BIOS 固件的系统)

    复制代码
    [root@localhost ~]# grub2-mkconfig >/boot/grub2/grub.cfg
  3. 重启后控制台不再有任何输出,所有⽇志保存在 /var/log/messages ⽇志中内容如下:

    复制代码
    Aug 1 09:00:40 localhost kernel: Command line: BOOT_IMAGE=(hd0,gpt2)/vmlinuz-4.18.0-
    348.el8.0.2.x86_64 root=/dev/mapper/rl-root ro crashkernel=auto resume=/dev/mapper/rl-swap
    rd.lvm.lv=rl/root rd.lvm.lv=rl/swap rhgb quiet
    Aug 1 09:00:40 localhost kernel: x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point registers'
    Aug 1 09:00:40 localhost kernel: x86/fpu: Supporting XSAVE feature 0x002: 'SSE registers'
    Aug 1 09:00:40 localhost kernel: x86/fpu: Supporting XSAVE feature 0x004: 'AVX registers'
    Aug 1 09:00:40 localhost kernel: x86/fpu: Supporting XSAVE feature 0x200: 'Protection Keys User
    registers'
    Aug 1 09:00:40 localhost kernel: x86/fpu: xstate_offset[2]: 576, xstate_sizes[2]: 256
    Aug 1 09:00:40 localhost kernel: x86/fpu: xstate_offset[9]: 832, xstate_sizes[9]: 8
    Aug 1 09:00:40 localhost kernel: x86/fpu: Enabled xstate features 0x207, context size is 840 bytes, using
    'compacted' format.
    Aug 1 09:00:40 localhost kernel: BIOS-provided physical RAM map:

这样,开机的时候,控制台就不会显⽰启动⽇志了。这不仅能让你的控制台看起来更加清爽,启动速度更快,同时也能更好地保护你的⽇志安全。

如果你有任何问题或者疑问,欢迎在评论区留⾔,我会尽我所能为你解答。

相关推荐
bantinghy4 小时前
Linux系统TCP/IP网络参数优化
linux·网络·tcp/ip
星期天要睡觉5 小时前
Linux 综合练习
linux·运维·服务器
saynaihe5 小时前
proxmox8升级到proxmox9
linux·运维·服务器
Orchestrator_me5 小时前
CentOS交换区处理
linux·运维·centos
zru_96025 小时前
centos 系统如何安装open jdk 8
java·linux·centos
FLS1685 小时前
VMwaer虚拟机安装完Centos后无法联网问题
linux·运维·centos
OctopusMonster5 小时前
centos下gdb调试python的core文件
linux·运维·centos
snowfoootball6 小时前
(自用)Linux 常用命令自查文档
linux·运维·服务器
R-G-B7 小时前
Linux常见命令总结 合集二:基本命令、目录操作命令、文件操作命令、压缩文件操作、查找命令、权限命令、其他命令
linux·基本命令·目录操作命令·linux常见命令·压缩文件操作·权限命令·查找命令
Chukai1237 小时前
Windows 和 Linux 系统下修改防火墙机制开放端口
linux·运维·windows