Linux – I can no longer login as root user (Raspberry Pi running Raspbian)

debian-wheezylinuxraspberry pi

Raspberry Pi running Raspbian (2014-01-07)

The error seems to have come from nowhere, as I was trying to log in as root via SSH (yes I have it activated – for now) I got the message "Access Denied" which felt wrong since I am the owner of the raspberry pi, I had set up the whole thing and I was the one who created the user's password. I went to the physical Raspberry Pi, hooked it up to a monitor, and tried to log in.

What followed was a failed attempt to access my pi, well, I could log in, but I was immediately met with the "MyHostName login:"

What I saw on-screen, step by step:

"MyHostName login:"

I entered "root" to log in as that user

"Password:" I entered my password and hit return.

Last login: Fri Mar 28 14:38:11 CET 2014 on tty1
Linux MyHostName 3.10.34+ #660 PREEMPT TUe Mar 25 15:04:00 GMT 2014 armv61

The programs included with the Debian Gnu/Linux [...]
permitted by applicable law.
No directory, logging in with Home=/
Cannot execute /root:bin:bash: No such file or directory

Raspbian GNU/Linux 7 MyHostName tty

MyHostName login:

As you can see I can, well not quite but still, log in – but I am immediately signed out again.

Unfortunately, I have not set up other sudoers so I can not access the /etc/passwd to try and correct whatever's wrong.

I had finally set it up as a LAMP-server, everything was up and running and now this…
All I hope is that I don't have to re-flash the SD.

Best Answer

This problem isn't related to the root password, it's related to the shell in /etc/passwd:

/root:bin:bash:

Your shell in /etc/passwd needs to exist, and should match an entry in /etc/shells.

Also, it appears the general format of your /root line is amiss, as it cannot identify the home directory field.

If single user mode doesn't work, you can always boot into some live device, such as USB drive, mount the / filesystem and edit /etc/passwd directly. The root line should look something like:

root:x:0:0:root:/root:/bin/bash
Related Question