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

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:
    

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

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

相关推荐
深度Linux13 分钟前
Linux网络编程中的零拷贝:提升性能的秘密武器
linux·linux内核·零拷贝技术
chian-ocean4 小时前
从理论到实践:Linux 进程替换与 exec 系列函数
linux·运维·服务器
拎得清n4 小时前
UDP编程
linux
敖行客 Allthinker4 小时前
从 UTC 日期时间字符串获取 Unix 时间戳:C 和 C++ 中的挑战与解决方案
linux·运维·服务器·c++
夏尔Gaesar6 小时前
Vim安装与配置教程(解决软件包Vim没有安装可候选)
linux·编辑器·vim
hunter2062066 小时前
如何监控ubuntu系统某个程序的运行状态,如果程序出现异常,对其自动重启。
linux·chrome·ubuntu
慕雪华年7 小时前
【Linux】opencv在arm64上提示找不到libjasper-dev
linux·运维·opencv
s_little_monster9 小时前
【Linux】从硬件到软件了解进程
linux·运维·服务器·经验分享·笔记·学习·学习方法
zyhhsss11 小时前
Ubuntu&Windows双系统安装
linux·运维·ubuntu
Marilynhom11 小时前
CentOs9新手教程
linux·centos