How to fix cursed machine with broken recovery mode and broken GNOME

Recovery mode shows a screen that apparently can’t find dpkg/apt/any coreutil executables: here, GNOME crashes after login attempt with correct password, systemctl status gdm shows:

Nov 02 16:38:19 (system name) systemd[1]: Starting gdm.service - GNOME Display Manager...
Nov 02 16:38:20 (system name) systemd[1]: Starting gdm.service - GNOME Display Manager.
Nov 02 16:38:20 (system name) gdm-launch-environment] [1005]: pam_env(gdm-launch-environment:session): deprecated reading f user environment enabled
Nov 02 16:38:20 (system name) gdm-launch-environment] [1005]: pam_unix(gdm-launch-environment:session): session opened for user gdm(uid=120) by (uid=0)
Nov 02 16:38:27 (system name) gdm-password] [2135]: (red text)gkr-pam: unable to locate daemon control file(end red text)
Nov 02 16:38:27 (system name) gdm-password] [2135]: gkr-pam: stashed password to try later in open session
Nov 02 16:38:27 (system name) gdm-password] [2135]: pam_env(gdm-password:session): deprecated reading of user environment enabled
Nov 02 16:38:27 (system name) gdm-password] [2135]: pam_unix(gdm-password:session): session open for user (my username)(uid=1000) by (uid=0)
Nov 02 16:38:27 (system name) gdm-password] [2135]: gkr-pam: unlocked login keyring
Nov 02 16:38:27 (system name) gdm-password] [2135]: pam_unix(gdm-password:session): session closed for user (my username)
Nov 02 16:38:27 (system name) gdm3[989]: (bold text)Gdm: GdmDisplay: Session never registered, failing(end bold text)

By coreutils being broken, I mean that all scripts that try to run coreutils fail. It’s fine if I type them out, but otherwise not. Also bash(and dash) doesn’t recognize built in commands like source and help but does recognize executables such as ls or cd.

Also, running startx does work.

Asked By: Averse ABFun

||

The behavior you’re describing suggests that you have overwritten the /bin/bash program with either a copy of, or a symbolic link to, a different shell – most likely /bin/dash (or /bin/sh, which by default is itself a symlink to dash):

  • dash doesn’t have a builtin help or source command (the latter is a bash synonym for the POSIX . command)

  • dash doesn’t support ksh-style arrays so for example

      $ sh -c 'items[c++]="resume"'
      sh: 1: items[c++]=resume: not found
    

To fix it you will likely need to re-install the bash package – it’s been a while since I tried it, but I believe sudo apt install --reinstall bash should work even when bash is currently dash (the package’s install scripts invoke bash, but don’t actually use any non-POSIX features).

One way this might have happened is if you’d attempted to symlink /bin/sh to bash instead of the default dash, but had got the source and target the wrong way around.

Answered By: steeldriver