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

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:

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

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

相关推荐
qq_401700416 小时前
Linux设备树详解
linux·运维·服务器
云梦谭6 小时前
让 Linux 主动连接 Windows:配置 Windows 11 SSH 服务端
linux·windows·ssh
刚入门的大一新生6 小时前
Linux-信号
linux·运维·服务器
GeW11 小时前
新质生产力路线图解读:数据库性能优化与Linux调优专场
linux
mounter62511 小时前
深入理解 gccrs:GCC 如何实现 Rust 编译器,以及编译 Linux 内核面临的挑战
linux·驱动开发·rust
垚垚学技术_聚焦云原生11 小时前
Ansible Playbook 进阶:when 条件、loop 循环、handlers 触发器落地
linux·ansible·自动化运维·devops
无足鸟ICT12 小时前
【RHCA+】type命令(判断命令类型)
linux·ssh·bash
咸鱼梦想家π12 小时前
Linux开发工具(下)
linux·运维·服务器
LHICOD12 小时前
Linux-1
linux·ip·vmware·虚拟机·cmd·ping
丰锋ff14 小时前
用户管理命令
linux·运维·服务器