I'm running a custom build of Debian buster/sid. I have broken a lot of things seemingly by mistakenly running apt-get dist-upgrade (I think that's what did it). So the desktop manager\desktop environment no longer loads at all and I just get a command-line shell.

Aptitude and apt-get are broken as is dpkg.

apt update, aptitude update and apt-get update fails and gives a lot of errors when attempted to run, however my /etc/apt/sources.list looks fine

deb http://ftp.ie.debian.org/debian unstable main contrib non-free
deb-src http://ftp.ie.debian.org/debian unstable main contrib non-free
deb http://ftp.ie.debian.org/debian experimental main contrib non-free
deb-src http:// ftp.ie.debian.org/debian experimental main contrib non free
deb https://dl.winehq.org/wine-builds/debian sid main
deb https://dl.winehq.org/wine-builds/ubuntu sid main

errors on update like this:

Err:2 http://ftp.ie.debian.org/debian unstable InRelease
Couldn't execute /usr/bin/apt-key to check /var/lib/apt/lists/partial/ftp.ie.debian.org_debian_dists_experimental_InRelease


E: Problem executing scripts APT::Update::Post-Invoke-Success '/usr/bin/test -e /usr/share/dbus-1/system-services/org.freedesktop.PackageKit.service && /usr/bin/test -S /var/run/dbus/system_bus_socket && /usr/bin/gdbus call --system --dest org.freedesktop.PackageKit --object-path /org/freedesktop/PackageKit --timeout 4 --method org.freedesktop.PackageKit.StateHasChanged cache-update > /dev/null; /bin/echo > /dev/null'

E: Sub-process returned an error code

aptitude upgrade, apt upgrade or apt-get upgrade appear to be broken due to dpkg being broken

Dpkg gives this error:

dpkg: warning: 'sh' not found in PATH or not executable
dpkg: error: 1 expected

however echo $PATH returns, which looks fine to me


if I try sh I get

The program 'sh' is currently not installed. To run 'sh' please ask your administrator to install the package 'dash'

If I try sudo apt-get install dash

it tells me dash is already the newest version (0.5.8-2.6)

and if I continue

E: Sub-process /usr/sbin/dpkg-preconfigure --apt || true returned an error code (100)
E: Failure running script /usr/sbin/dpkg/preconfigure --apt || true

If I run sudo nano /etc/apt/apt.conf.d/70debconf and comment out the line DPkg::Pre-Install-Pkgs {"/usr/sbian/dpkg-preconfigure --apt || true";};

then aptitude fails with

dpkg: warning: 'sh' not found in PATH or not executable
dpkg: error: 1 expected

So I can't reinstall necessary packages to restore the system because dpkg (and therefore aptitude, apt-get, apt) are broken, seemingly because sh is not in my PATH. However all the correct directories are in my PATH. I'm assuming that fixing this issue with sh would allow dpkg and aptitude to work again but I'm wondering what precisely is the problem with sh?

Thank you in advance for any help.


ls -l /bin/bash


-rwxr-xr-x 1 root root 1099016 May 15  2017 /bin/bash

ls -l /bin/sh returns

lrwxrwxrwx 1 root root 4 Jun 28  2017 /bin/sh -> dash

ls -l /bin/dash returns

ls: cannot access 'bin/dash': No such file or directory

So /bin/sh seems to redirect to /bin/dash which has been deleted somehow?

sudo apt-get install --reinstall dash fails with:

1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.    
E: Internal Error, No file name for dash:amd64

Running sudo ln -sf bash /bin/sh and then sudo apt-get install --reinstall dash fails with the same error as above.

Searching for this issue and variants of it on Google I've found numerous solutions related to the user's PATH and permissions, I've checked the files which relate to that including /etc/sudoers /root/.bashrc and /root/.profile and /etc/profile. In most of those cases the users were able to solve their issue by simply defining their path correctly (usually the /sbin or /usr/sbin directories were missing). As stated above my PATH seems to contain all the relevant directories whether I run echo $PATH normally or as root or sudo echo $PATH. Some users were also having issues with permissions or with sudo itself. I've also tried executing various aptitude apt and apt-get and dpkg commands as root using sudo -i which suggests that my issue is different.

  • 2
    What is the output of ls -l /bin/??sh? I would expect /bin/sh to be a symbolic link to either bash or dash - maybe the link just got broken or deleted? – steeldriver Jan 27 '18 at 1:56
  • 2
    I'm voting to close this question as off-topic because it's a request for troubleshooting assistance, and does not contain an answerable question. More details would be necessary for it to be answerable. Please edit the question to include all relevant details (beginning by answering questions raised in comments). – Wildcard Jan 27 '18 at 2:53
  • Thanks for your input, do you have any suggestions as to how I could make this post more appropriate for this forum (eg; what information I'm missing that I should include?) Not being facetious but I'm relatively new to this site. – Fearg Jan 27 '18 at 3:07
  • 1
    Hmmm, you may be able to work around the issue by running: sudo ln -sf bash /bin/sh and then running sudo apt-get install --reinstall dash. So use bash as your sh shell temporarily. – Wildcard Jan 27 '18 at 3:29
  • apt-get prompts me to remove automatically installed packages linux-image-4.8.0-1-amd64 linux-image-4.9.0-2-amd64 linux-image-4.9.0-3-amd64 using sudo apt autoremove I've ignored it up to this point as I assume it to be irrelevant and am somewhat less trusting of its judgement at the moment, but would you recommend I go ahead with that? – Fearg Jan 27 '18 at 3:38

You were bitten by a nasty bug in dash which caused /bin/sh to be removed. This has since been fixed, which is why another apt update and apt full-upgrade fixed it (after restoring /bin/sh to point to bash presumably, your comments aren’t clear about that).


As stated by @Stephen Kitt I had encountered this bug in dash which had broken sh (the Bourne shell) as /bin/sh is a symlink to /bin/dash/ in my particular distribution.

Running sudo ln -sf bash /bin/sh in order to point sh to bash and then running sudo apt-get update followed by sudo apt-get install --reinstall dash followed by sudo apt-get full-upgrade solved the issue.

  • Life saver. I though I had to do a reinstall – LnxSlck Nov 23 '20 at 22:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.