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

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:

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

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

相关推荐
Android系统攻城狮1 小时前
Linux PipeWire深度解析之pw_factory_create_object调用流程与实战(七十二)
linux·音频进阶·pipewire音频进阶
lsh曙光2 小时前
playbook剧本(2)--Ansible变量
linux·运维·网络
lengjingzju2 小时前
编译与调试完全指南—第14章 系统配置与调优
linux
大鹏的NLP博客3 小时前
通用 Linux 嵌入式板端 C/C++ ABI 与 Glibc 依赖治理规范
linux·c++·交叉编译
tedcloud1233 小时前
book-to-skill 怎么部署?把技术书和项目文档变成 AI Agent 可复用知识
linux·运维·服务器·人工智能·开源
瀚高PG实验室4 小时前
SQL优化案例:使用分区表优化SQL查询性能
linux·服务器·数据库·sql·microsoft·postgresql
青禾8374 小时前
Linux 系统信息、权限管理与 Python 并发编程(协程与线程)完全指南
linux·python
2301_800954994 小时前
Linux 常用系统信息与进程管理命令速查
linux·运维·服务器
T型码农要学习5 小时前
eMMC_命令整理
linux·驱动开发·emmc
刚入门的大一新生6 小时前
Linux-进程4
linux·运维·服务器