root passwd

Hi all, Noobie to linux. Accidentally removed my root password. Tried doing
sudo -i
sudo -i
to set it, and it returned
password updated successfully,
password updated successfully,
but doing
sudo -i
sudo -i
again didn't prompt me for a password. What am I doing wrong here?
Solution:
then disable and lock the root account
Jump to solution
23 Replies
termdisc
termdisc2mo ago
How soon after the first sudo command are you running the next one? The password is effectively cached for a little bit before you have to reenter it
HikariKnight
HikariKnight2mo ago
cached for 5-7 mins by default in most distros isnt it?
frostcrackle
frostcrackleOP2mo ago
I restarted my pc after setting the password. Does that clear the cache? Interestingly, after doing
passwd
passwd
while logged into root, the password actually applied to my user account (dan). My root account was still passwordless
HikariKnight
HikariKnight2mo ago
the root account (named root) is disabled only able to be logged into using sudo su and should never be enabled for direct login if you need root permissions use sudo, which will ask for your normal admin users password
frostcrackle
frostcrackleOP2mo ago
mb, i didn't mean login as in through the login screen, i just meant i tried using some sudo commands and was not met with a password prompt
HikariKnight
HikariKnight2mo ago
which you set with passwd without sudo restarting will clear the cached password you can also force the password to be asked for again by invalidating the cache with sudo -k commandyouwanttorun
frostcrackle
frostcrackleOP2mo ago
sudo -k nano /test.txt didn't prompt me for a password i have done the following: sudo -i passwd (set password here) Password updated successfully. tried a sudo command, no password prompt. restarted pc tried another sudo command, still no password prompt
HikariKnight
HikariKnight2mo ago
sudo passwd -dl root i think is how you re-disable the root password however make sure that sudo from your admin account works first so you dont lock yourself out without admin access anyways i need to go get some sleep its almost 3am
frostcrackle
frostcrackleOP2mo ago
oh yeah i should note, i did sudo passwd -d dan which is how i ended up with no root password good night! thanks for the assistance
HikariKnight
HikariKnight2mo ago
that removed your password just set it with passwd again
frostcrackle
frostcrackleOP2mo ago
i thought passing a user to the command deleted it for that user only?
HikariKnight
HikariKnight2mo ago
yes but running without a password is a super dumb idea and youre effectively giving us devs a license to make fun of you since its worse than not changing the default password
frostcrackle
frostcrackleOP2mo ago
didn't really intend to get made fun of, just thought that having a password on the root user would be sufficient again, linux noobie
HikariKnight
HikariKnight2mo ago
its ok its your users password that is used when you elevate with sudo not the root password but doing sudo -i followed by passwd will set the password for the root account but if you already ran sudo passwd -d dan you would have made sudo require no password and the other one would have made it so the root account login would work
frostcrackle
frostcrackleOP2mo ago
that makes more sense. interesting interaction though, i thought running sudo would ask for the root password. learned something new today so running sudo will always ask for the current user's password?
HikariKnight
HikariKnight2mo ago
yes
frostcrackle
frostcrackleOP2mo ago
i should add, even if i have a root password set?
HikariKnight
HikariKnight2mo ago
and if the user is in the wheel group (admin group) then you get root permissions for the 1 command having a root password set is highly not recommended elevate using sudo and your own password this is why we disable the root password configuration in the installer so the root account stays disabled, because people keep footgunning no, footshotgunning themselves repeatedly
frostcrackle
frostcrackleOP2mo ago
i personally prefer footrocketlauncher but that's just me. well, thanks for disabling that functionality to protect people like myself XD. all i have to do is set my dan password right? side note, is there any way to make it so i don't have to enter my password on boot? while still maintaining a user password
HikariKnight
HikariKnight2mo ago
set password on your account
Solution
HikariKnight
HikariKnight2mo ago
then disable and lock the root account
HikariKnight
HikariKnight2mo ago
enable autologin
frostcrackle
frostcrackleOP2mo ago
Those both worked for me. Thank you!
Want results from more Discord servers?
Add your server