What is the default password for root?

I've already changed the username and password for the default login, but I wan to change the password for the root user.

Attempted the default password for the default user 'raspberry' as well as my new password.

OctoPrint version : 1.3.12
OctoPi version : 0.17.0

Headless install

It's not intended that you log in as the root user. You have to use sudo instead.

If you really have to have a root password, just

sudo passwd root

1 Like

By default, there is no way to log in as root, so there is no need to change the password. Logging in as root should not be necessary.

And keep in mind that you can't login as root via ssh with the default ssh config.
Either change the config (not recommend) or switch to root after you logged in as pi with su -

1 Like

Yup, that's how I tried to login as root. Didn't work.

So, the passwd file's been changed to sbin/nologin?

sudo bash
... # do your risky bizness
exit

Yes, I know how sudo works. I'm trying to understand how Octopi is set up.

You should check out the Octopi github repository if you want to know it in detail

Though this detail in particular is more how raspbian is set up

1 Like

True but iirc they changed a thing and that's the reason why you need a password for sudo on octopi.
I can't test it right now but I think there was a post mentioning it a while ago.
But yeah that shouldn't change anything else.

Thank you. I'll crawl through that.

If you changed the username pi then you might want to also update the references to that in /etc/sudoers.d/*.

Already adjusted group permissions and such but I appreciate the note.

I completely forgot about SuperUser...

I need the root password because I accidentally messed up my sudoers file. Now I have to use pkexec visudo to fix it. But it asks for the root password. I tried raspberry, my password for the pi account, and leaving it blank - no luck. Is there some other way to fix the sudoers file? The error I'm getting any time I try to use sudo is:

>>> /etc/sudoers: syntax error near line 27 <<<
sudo: parse error in /etc/sudoers near line 27
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin

TIA

afaik there is no root password set. if you want to set one you have to run sudo passwd root (what you obviously can't do right now)
I suggest you mount the sd card on an other linux system and edit the file there

My first thought was I don't have another Linux system, but then I realized that I did have another SD card and could easily create another Linux system. I flashed it with Octopi and booted my Pi with it. I put the original SD card in a USB reader and plugged it in. Mounted the drive (had to google that for a refresher on how to do it) and edited the file.

The problem was the last line:
#includedir /etc/sudoers.d

I thought to enable the inclusion of the sudoers.d directory, I had to uncomment it. I didn't realize that with the # it was actually a command.

I did use visudo but ignored the warning at the end. Wasn't sure what it meant and didn't realize that it was about to do something very bad to the OS!

So I set the password for the root account. But now when I try pkexec visudo it gives me this error:
polkit-agent-helper-1: error response to PolicyKit daemon: GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: No session for cookie
I googled it but I'm afraid the explanations I found were beyond my understanding of Linux. Oh, well, no problem. I know how to fix the sudoers file in the future. I also know how important it is to use visudo and pay attention to its error messages! Keeping the extra SD card handy just in case.

Thanks for the help!

In a case like this where you've painted yourself into a corner, the easiest solution is to boot from another Linux, fix the problem and then reboot back to the original root file system.

In other words, move the microSD card to a laptop with Ubuntu running on it. Or use a live Ubuntu USB drive to temporarily boot up the Pi in-place. But this is problematic so I'd recommend the first option.

1 Like