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

6,433

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
Share:
6,433

Related videos on Youtube

Alex
Author by

Alex

Updated on September 18, 2022

Comments

  • Alex
    Alex almost 2 years

    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.

    • Nathan C
      Nathan C about 10 years
      Something is screwy. Boot it into single-user mode. You'll need to connect the Pi to a monitor, though.
    • Nathan C
      Nathan C about 10 years
      On that note, if you have another linux machine laying around (or set up Windows so it can read ext partitions) you can pop the SD card into your computer and modify the files directly.
    • Alex
      Alex about 10 years
      @NathanC I thought of that too, but from what I could find, all the extensions available only allows to read the partition and not write to it.
    • Nathan C
      Nathan C about 10 years
      Try ext2fsd.com perhaps?
    • Alex
      Alex about 10 years
      @NathanC When I have installed it, I insert my SD Card, open the Manager and click on the linux partition of the drive, correct? When I then click on "Add mount point" and proceed to try to add one, the program freezes for a second or two indicating something is happening, but the drive won't mount. No error messages or anything.
    • Nathan C
      Nathan C about 10 years
      I've never tried it myself and I don't have a way to test unfortunately. Your best bet is to try single user mode.
    • Alex
      Alex about 10 years
      Going into single user mode and then editing the /etc/passwd solved it. I will answer my question later for any possible bycomers. I really have to learn more, these things should be tought in school! Thanks, Nathan. Have a great weekend.
  • Kamil Maciorowski
    Kamil Maciorowski about 7 years
    It's worth to mention two things: (1) To avoid such errors in /etc/passwd use vipw tool. (2) Booting into a live device may not be easy with Raspberry Pi; mounting its SD card in another Linux machine and editing from there may be a lot easier.