5

I know it has been asked many times before but none of those solutions helped me.

Every time I am running sudo apt upgrade I get this error.

dpkg: error processing package systemd (--configure):
 installed systemd package post-installation script subprocess returned error exit status 127
Errors were encountered while processing:
 systemd
E: Sub-process /usr/bin/dpkg returned an error code (1)

And sudo dpkg --configure -a returns

  Setting up udev (237-3ubuntu10.28) ...
/var/lib/dpkg/info/udev.postinst: 108: /var/lib/dpkg/info/udev.postinst: addgroup: not found
dpkg: error processing package udev (--configure):
 installed udev package post-installation script subprocess returned error exit status 127
Setting up systemd (237-3ubuntu10.28) ...
/var/lib/dpkg/info/systemd.postinst: 123: /var/lib/dpkg/info/systemd.postinst: addgroup: not found
dpkg: error processing package systemd (--configure):
 installed systemd package post-installation script subprocess returned error exit status 127
dpkg: dependency problems prevent configuration of libnss-systemd:amd64:
 libnss-systemd:amd64 depends on systemd (= 237-3ubuntu10.28); however:
  Package systemd is not configured yet.

dpkg: error processing package libnss-systemd:amd64 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of libpam-systemd:amd64:
 libpam-systemd:amd64 depends on systemd (= 237-3ubuntu10.28); however:
  Package systemd is not configured yet.

dpkg: error processing package libpam-systemd:amd64 (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 udev
 systemd
 libnss-systemd:amd64
 libpam-systemd:amd64

I don't think it's safe to remove systemd package all together. Any help is appreciated and I am on Ubuntu 18.04.

4
  • 1
    You need to read further back in your messages; you provided only the final summary "script subprocess returned error exit status 127" from the calling routine; the actual error message was listed earlier in the called routine which provides the clue as to problem and thus fix. Full messages (including command) are best, unless you know what you can cull/reduce.
    – guiverc
    Commented Sep 8, 2019 at 7:01
  • Can you please check now I updated the second trackback Commented Sep 8, 2019 at 7:07
  • dpkg -l | grep adduser and dpkg -l | egrep -v '^ii|rc' please.
    – nobody
    Commented Sep 8, 2019 at 11:26
  • does any body have solution of this? Commented Feb 12, 2020 at 17:38

2 Answers 2

5

With

stat / /dev /var

check if you are the owner of all directories. If not, run:

chown root DirectoryYouAreNotOwner

In my case, the owner of / was Unknown. So I used the command:

chown root /
2
  • Thanks. This worked for me. Didn't know how /'s owner had been changed. Commented Feb 8, 2021 at 15:47
  • For me it was mpd:audio for some reason!
    – i336_
    Commented Apr 16, 2022 at 4:53
3

The answer of Miguel Saldanha did not work for me and I tried searching a bit more. Finally, the answer from this post helped me. Just posting the answer here because this has been referred in several places and in case someone needs it in future.

sudo rm /var/lib/dpkg/info/systemd*
sudo dpkg --configure -D 777 systemd
sudo apt -f install

Hope it helps.

3
  • In case deleting things with "system" in the name makes you nervous, you can back the files up first: mkdir ~/sysdbu/ && sudo cp /var/lib/dpkg/info/systemd* ~/sysdbu/ Commented Jul 27, 2021 at 23:16
  • This did solve my problem, though now I get warnings about those files missing whenever I apt-get something. Not sure how serious those will be going forward, but I needed to move past this now. Thanks! Commented Jul 27, 2021 at 23:17
  • 2
    Thanks Shahad, you saved my day!
    – Pekov
    Commented Aug 20, 2021 at 15:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .