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

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:

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

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

相关推荐
落羽的落羽2 分钟前
【网络】TCP与UDP协议使用指南,Socket编程实现Echo服务
linux·服务器·网络·c++·网络协议·tcp/ip·机器学习
草莓熊Lotso28 分钟前
LangChain从入门到精通:环境搭建→核心能力→LCEL链式编程全实战
android·java·linux·服务器·langchain
GanGanGanGan_9 小时前
RustDesk 安装指南 — Rocky Linux 9 + XFCE X11
linux·运维·centos
南境十里·墨染春水13 小时前
linux学习笔记 网络编程——Socket入门与TCP客户端/服务器实现
linux·服务器·网络
Yupureki14 小时前
《Linux网络编程》6.UDP原理
linux·运维·服务器·网络·udp
楼田莉子14 小时前
Linux网络:NAT_代理
linux·运维·服务器·开发语言·c++·后端
烛衔溟15 小时前
TypeScript 索引签名、只读数组与 keyof / typeof 入门
linux·ubuntu·typescript
笨笨饿16 小时前
#79_NOP()嵌入式C语言中内联汇编宏的抽象封装模式研究
linux·c语言·网络·驱动开发·算法·硬件工程·个人开发
fish_xk16 小时前
Linux的权限
linux·运维·服务器
嵌入式×边缘AI:打怪升级日志17 小时前
Linux 驱动与应用开发核心自测题库(面试官问答完整版)
linux·运维·php