升级时 /etc/default/grub 出现 dpkg 错误

升级时 /etc/default/grub 出现 dpkg 错误

我的机器上安装了 22.04.2 版 Jammy Jellyfish。当我尝试进行更新和升级时,出现以下错误。你们当中有人知道是什么原因造成的吗?并建议如何修复它?非常感谢

Processing triggers for linux-image-5.19.0-38-generic (5.19.0-38.39~22.04.1) ...

/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.19.0-38-generic

I: The initramfs will attempt to resume from /dev/dm-1
I: (/dev/mapper/vgxubuntu-swap_1)
I: Set the RESUME variable to override this.

/etc/kernel/postinst.d/zz-update-grub:
Sourcing file `/etc/default/grub'
/usr/sbin/grub-mkconfig: 36: /etc/default/grub: bash:: not found
run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 127

dpkg: error processing package linux-image-5.19.0-38-generic (--configure):
 installed linux-image-5.19.0-38-generic package post-installation script subpro
cess returned error exit status 1

Errors were encountered while processing:
 linux-image-5.19.0-38-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)

cat /etc/default/grub以下是Baa 建议的命令的输出:

hetrengzy@hefto-Ubuntu:~$ cat /etc/default/grub

# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=menu
GRUB_TIMEOUT=45
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"


bash: line 1: J: command not found

您能建议如何处理这个问题吗?非常感谢

答案1

有一行代码是/etc/default/grub导致问题的根源bash: line 1: J: command not found。不知道它是怎么出现的,但只要删除它就行了。

  1. 使用命令sudo gedit /etc/default/grub在文本编辑器中打开此文件。
  2. bash: line 1: J: command not found找到末尾的那一行。
  3. 删除整行,注意不要修改文件中的任何其他内容。
  4. 保存并关闭编辑器。
  5. 尝试再次更新。

相关内容