1

This is what happens whenever I try to install something through the terminal:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
wget is already the newest version (1.20.3-1ubuntu1).
wget set to manually installed.
build-essential is already the newest version (12.8ubuntu1.1).
build-essential set to manually installed.
libssl-dev is already the newest version (1.1.1f-1ubuntu2.4).
libssl-dev set to manually installed.
The following package was automatically installed and is no longer required:
  linux-modules-5.8.0-49-generic
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
  libncurses-dev libnspr4-dev
Suggested packages:
  ncurses-doc readline-doc
The following packages will be REMOVED:
  linux-image-5.8.0-49-generic
The following NEW packages will be installed:
  libffi-dev libgdbm-dev libncurses-dev libncurses5-dev libnspr4-dev libnss3-dev libreadline-dev zlib1g-dev
0 upgraded, 8 newly installed, 1 to remove and 7 not upgraded.
3 not fully installed or removed.
Need to get 1.214 kB of archives.
After this operation, 2.901 kB disk space will be freed.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu focal/main amd64 libgdbm-dev amd64 1.18.1-5 [83,4 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal/main amd64 libncurses-dev amd64 6.2-0ubuntu2 [339 kB]
Get:3 http://archive.ubuntu.com/ubuntu focal/main amd64 libncurses5-dev amd64 6.2-0ubuntu2 [976 B]
Get:4 http://archive.ubuntu.com/ubuntu focal/main amd64 libnspr4-dev amd64 2:4.25-1 [206 kB]
Get:5 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libnss3-dev amd64 2:3.49.1-1ubuntu1.5 [231 kB]
Get:6 http://archive.ubuntu.com/ubuntu focal/main amd64 libreadline-dev amd64 8.0-4 [141 kB]
Get:7 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 zlib1g-dev amd64 1:1.2.11.dfsg-2ubuntu1.2 [155 kB]
Get:8 http://archive.ubuntu.com/ubuntu focal/main amd64 libffi-dev amd64 3.3-4 [57,0 kB]
Fetched 1.214 kB in 0s (2.750 kB/s)   
(Reading database ... 290766 files and directories currently installed.)
Removing linux-image-5.8.0-49-generic (5.8.0-49.55~20.04.1) ...
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-5.8.0-49-generic
/etc/kernel/postrm.d/zz-update-grub:
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Script `/boot/grub/grub.cfg.new' contains no commands and will do nothing
Syntax errors are detected in generated GRUB config file.
Ensure that there are no errors in /etc/default/grub
and /etc/grub.d/* files or please file a bug report with
/boot/grub/grub.cfg.new file attached.
run-parts: /etc/kernel/postrm.d/zz-update-grub exited with return code 1
dpkg: error processing package linux-image-5.8.0-49-generic (--remove):
 installed linux-image-5.8.0-49-generic package post-removal script subprocess returned error exit status 1
dpkg: too many errors, stopping
Errors were encountered while processing:
 linux-image-5.8.0-49-generic
Processing was halted because there were too many errors.
E: Sub-process /usr/bin/dpkg returned an error code (1)

Unfortunately it won't tell me the error line number, so I don't know what to even look for.

This is the content of my /etc/default/grub:

GNU nano 4.8                                                                                 /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=hidden GRUB_TIMEOUT=0 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"

I don't know if this helps but just in case... When I run:

sudo nano /etc/grub.d/*

nano opens up and gives this message at the bottom:

[ Directory '/etc/grub.d' does not exist ]

And dpkg -C:

The following packages are only half configured, probably due to problems
configuring them the first time.  The configuration should be retried using
dpkg --configure <package> or the configure menu option in dselect:
 grub-pc              GRand Unified Bootloader, version 2 (PC/BIOS version)
 linux-image-5.8.0-53-generic Signed kernel image generic

The following packages are only half installed, due to problems during installation. The installation can probably be completed by retrying it; the packages can be removed using dselect or dpkg --remove: linux-image-5.8.0-49-generic Signed kernel image generic

Running the commands dpkg --configure for grub-pc and linux-image, as suggested in the above output, gives:

$ sudo dpkg --configure grub-pc
[sudo] password for reagan: 
Setting up grub-pc (2.04-1ubuntu26.11) ...
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Script `/boot/grub/grub.cfg.new' contains no commands and will do nothing
Syntax errors are detected in generated GRUB config file.
Ensure that there are no errors in /etc/default/grub
and /etc/grub.d/* files or please file a bug report with
/boot/grub/grub.cfg.new file attached.
dpkg: error processing package grub-pc (--configure):
 installed grub-pc package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 grub-pc
$ sudo dpkg --configure linux-image-5.8.0-53-generic
    Setting up linux-image-5.8.0-53-generic (5.8.0-53.60~20.04.1) ...
    Processing triggers for linux-image-5.8.0-53-generic (5.8.0-53.60~20.04.1) ...
    /etc/kernel/postinst.d/dkms:
     * dkms: running auto installation service for kernel 5.8.0-53-generic
       ...done.
    /etc/kernel/postinst.d/initramfs-tools:
    update-initramfs: Generating /boot/initrd.img-5.8.0-53-generic
    /etc/kernel/postinst.d/zz-update-grub:
    Sourcing file `/etc/default/grub'
    Sourcing file `/etc/default/grub.d/init-select.cfg'
    Generating grub configuration file ...
    Script `/boot/grub/grub.cfg.new' contains no commands and will do nothing
    Syntax errors are detected in generated GRUB config file.
    Ensure that there are no errors in /etc/default/grub
    and /etc/grub.d/* files or please file a bug report with
    /boot/grub/grub.cfg.new file attached.
    run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 1
    dpkg: error processing package linux-image-5.8.0-53-generic (--configure):
     installed linux-image-5.8.0-53-generic package post-installation script subprocess returned error exit status 1
    Errors were encountered while processing:
     linux-image-5.8.0-53-generic

When running nano /boot/grub/grub.cfg.new:

#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#
         [ File '/boot/grub/grub.cfg.new' is unwritable ]

Running nano /boot/grub/grub.cfg is the same thing plus a big list of if...else statements.

  • 3
  • Not really.. nothing happens when i run that command – ReaganS94 May 23 '21 at 18:22
  • If you can't figure out which process is responsible for the lock, reboot the device. Make sure that you always run sudo apt update before any other commands in apt or apt-get. If you still have problems after reboot and updating the list of available software, plase return and edit your question with complete details – Nmath May 23 '21 at 18:55
  • @Nmath I've tried to turn the system off but it keeps getting in a loop [97431.056879] reboot: Power downand end up having to shut it off manually. Nothing changes though. Still the same errors. – ReaganS94 May 24 '21 at 07:49
  • 1
    Let's execute some of the commands what are mentioned in the output of dpkg -C. Execute dpkg --configure grub-pc and dpkg --configure linux-image-5.8.0-53-generic. Paste the outputs of the command in the question. – Random Person May 24 '21 at 13:19
  • I don't see the word 'locked' in any of the posted output...it looks like it's complaining about the content of /boot/grub/grub.cfg.new, it should be relatively similar to /boot/grub/grub.cfg. – rtaft May 24 '21 at 13:45
  • @rtaft the question has been significantly (iteratively) edited. – Organic Marble May 24 '21 at 13:49
  • @rtaft /boot/grub/grub.cfg.new displays this: ` #

    DO NOT EDIT THIS FILE

    It is automatically generated by grub-mkconfig using templates

    from /etc/grub.d and settings from /etc/default/grub

    #`

    – ReaganS94 May 24 '21 at 13:53
  • 1
    @OrganicMarble I missed that. – rtaft May 24 '21 at 13:59
  • 1
    If you can't shut down or reboot you have a much bigger problem. When did the problem start? What changes were made to the system around the same time that you lost the ability to reboot, shut down, update, and install software? – Nmath May 24 '21 at 18:28
  • @Nmath I can shut down and reboot, I don't have problems with that. This problem has been around for a few months now! I tried to post a question back then but unfortunately never got any answers. The terminal error screen has changed a bit over time though: in the beginning it used to show a lot more dpkg errors but now it's limited to grub and linux-image. As for the question "what did you *uck around with, nothing comes in mind. Didn't mess with any important file, this appeared after a download from the terminal got stuck in a loop and had to kill the process. – ReaganS94 May 24 '21 at 18:42
  • 1
    Your comments do not agree with each other. You said "I've tried to turn the system off but it keeps getting in a loop... and end up having to shut it off manually". If this is true, then you cannot say that you don't have problems with shutdown/reboot. If you have multiple system problems, and you haven't been able to resolve them after several months, you should probably reinstall the operating system. It's not a good idea to continue using a system that is severely broken, because it won't get better and new problems can spawn from unfixed ones. – Nmath May 24 '21 at 19:28
  • 1
    In the future if you experience a serious system problem like the inability to properly shut down, or inability to update software or install new software, you should make note of any changes or irregularities with the system prior to the problem's onset. This could be all sorts of things, like installing or updating software, making changes to configuration files, installing a different operating system, or experiencing an error in an application. If you wait several months, human memory is pretty bad, and it will be nearly impossible to check logs that far back. – Nmath May 24 '21 at 19:31
  • @Nmath You're right, the inability to properly shut down is a problem, but it just looks a little less significant compared to the bigger installation problem as I can force shut down with a button but can't do anything about the downloads/installations. About the "In the future..." tip: duly noted. I realize only now how stupid that was of me. I had just switched to Ubuntu and didn't really understand 100% of everything I was doing. Going forward I will, hopefully, gather more and more knowledge and improve the way I move around the system. – ReaganS94 May 24 '21 at 19:50
  • But is there anything I can do about this now? Is the damage reparable? What would you all suggest doing? – ReaganS94 May 24 '21 at 19:52
  • 1
    If you can't determine the source or solution to a problem, it sometimes helps to ask yourself if it will take less time and effort to cleanly reinstall the OS compared to searching for the cause(s) of problem (s). As far as not being able to shutdown properly, forced shutdown can easily cause new problems with your software. If it were me, I would reinstall the OS. Assuming you keep good backups, it doesn't take long to spin up and set up a new installation. – Nmath May 24 '21 at 23:02
  • Please copy the contents of /home/<YOUR_USERNAME>/.bash_history in a pastebin (like https://paste.ubuntu.com/) and share the link. I'll try to go through your terminal history and try to find the issue. – Random Person May 25 '21 at 13:51
  • I went for a clean reinstall, as Nmath suggested. Finding the error was taking far too long. Thanks to everyone for your time. Weird thing is.. even now with a reinstall I'm still getting the shutdown problem. Sigh. – ReaganS94 May 26 '21 at 07:57

0 Answers0