错误,当我进入 root sudo -s

错误,当我进入 root sudo -s

Linux 新手。我正在使用:

uname -r
5.15.0-30-generic
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04 LTS
Release:    22.04
Codename:   jammy

首先我尝试增加 tty 字体,编辑文件:.bashrc 使用了给出的建议: https://unix.stackexchange.com/questions/49779/can-i-change-the-font-of-the-text-mode-console sudo nano .bashrc;最后添加了以下几行:

# Set font when running in console
/bin/setfont /usr/share/consolefonts/Lat2-Terminus32x16.psf.gz    

# Splash Calendar and time
now

# ASCII Linux distribution display
screenfetch

启动终端时开始出现错误,例如:无法获取指向控制台的文件描述符再次删除这 3 行,以便获得原始的 .bashrc 文件

现在错误“无法获取引用控制台的文件描述符”不再发生,但当我转到根目录时仍然出现错误

sudo -s
Command 'now' not found, did you mean:
  command 'nsw' from snap nsw (0+git.b61ddec)
  command 'nop' from deb graphviz (2.42.2-6)
  command 'new' from deb mmh (0.4-4)
  command 'new' from deb nmh (1.7.1-11)
  command 'nox' from deb nox (2022.1.7-1)
  command 'sow' from deb ruby-hoe (3.22.1+dfsg1-2)
  command 'cow' from deb fl-cow (0.6-4.2)
  command 'nw' from deb netrw (1.3.2-3)
See 'snap info <snapname>' for additional versions.
Command 'screenfetch' not found, but can be installed with:
apt install screenfetch

有什么帮助吗?

答案1

这听起来好像你更改了.bashrcroot 用户的文件,而不是当前用户的文件。打开该文件:

sudoedit /root/.bashrc

并删除仍可见的三行。

解释:使用sudo会将 root 用户的 shell 更改为 。因此,在显示提示符之前,将读取并解释 root 用户的 shell 初始化文件。使用 时bash,交互式终端的初始化文件为.bashrc,因此/root/.bashrc对于 root 用户而言。

相关内容