1

My Ubuntu 16.04 is suddenly started booting in to the tty1 mode. I'm not able to use gui by pressing ctrl+alt+f7. When I login in tty mode it says

-bash: /usr/bin/lesspipe: /bin/sh: bad interpreter: No such file or directory

I also tried startx and got this error

-bash: /usr/bin/startx: /bin/sh: bad interpreter: No such file or directory

How could I solve this problem and Why this happened suddenly?

01000110
  • 183
  • 2
  • 9

1 Answers1

1

It sounds very much like your /bin/sh and/or your /bin/dash executable got borked somehow.

First, let's try to reinstall dash:

sudo apt update
sudo apt install --reinstall dash

Then, reboot. If your system still doesn't work, we just need to relink it to /bin/dash using this command:

sudo ln -fs /bin/dash /bin/sh

Give your machine a reboot just to ensure everything is cleared out of memory, and then try logging in.

The -f option on ln will force the system to build a link, even though the file already exists.


If your system complains that dash can not be downloaded, run this command to install the latest version from the Xenial repos directly.

If you have a 64-bit system (the majority of people):

wget http://us.archive.ubuntu.com/ubuntu/pool/main/d/dash/dash_0.5.8-2.1ubuntu2_amd64.deb -qO dash.deb && sudo dpkg -i dash.deb && rm dash.deb

If you have a 32-bit system:

wget http://archive.ubuntu.com/ubuntu/pool/main/d/dash/dash_0.5.8-2.1ubuntu2_i386.deb -qO dash.deb && sudo dpkg -i dash.deb && rm dash.deb

You can check your architecture by running arch. If it returns x86_64, you have a 64-bit system. Otherwise, you have a 32-bit system or some weird system.

Kaz Wolfe
  • 34,122
  • 21
  • 114
  • 172
  • I tried wget http ... for 32-bit system, it didn't output anything and then I rebooted the system and I am still in tty mode! :( – 01000110 Apr 11 '17 at 20:10
  • @01000110 Are you sure you're on a 32-bit computer? Also note that you'll need to type it in *exactly* as it appears in my answer. – Kaz Wolfe Apr 11 '17 at 20:10
  • Yes, I'm sure that it's 32-bit and typed it correctly. Maybe there is a problem with the internet connection? – 01000110 Apr 11 '17 at 20:15
  • @01000110 Run the part of the command before the first && and remove the q from the -qO and see what the output is. (So, just wget http://archive.ubuntu.com/ubuntu/pool/main/d/dash/dash_0.5.8-2.1ubuntu2_i386.deb -O dash.deb) – Kaz Wolfe Apr 11 '17 at 20:19
  • failed: Temporary failure in name resolution. wget: unable to resolve host address archive.ubuntu.com !! – 01000110 Apr 11 '17 at 20:21
  • I added nameserver 8.8.8.8 to the first line of /etc/resolv.conf and re-run the command. now it says dash.deb saved. – 01000110 Apr 11 '17 at 20:34
  • Now by executing wget http://archive.ubuntu.com/ubuntu/pool/main/d/dash/dash_0.5.8-2.1ubuntu2_i386.deb -O dash.deb && sudo dpkg -i dash.deb && rm dash.deb I get this Error: dpkg: warning: 'sh' not found in PATH or not executable dpkg: error: 1 expected program not found in PATH or not executable – 01000110 Apr 11 '17 at 20:37
  • @01000110 Oh boy. That's fun. Can you come meet me in a chatroom to solve this issue? – Kaz Wolfe Apr 11 '17 at 20:47