Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hmm, I'd recommend booting with a LiveCD and mounting your root parition. Chroot into it, and you might get a prompt that says 'I have no name!'. The steps are:
Code:
mkdir /tmp/temproot
mount /dev/sda1 /tmp/temproot (where sda1 is where your / partition is installed)
chroot /tmp/temproot
Edit /etc/passwd and add a line on top like this (or make sure it exists):
Code:
root:x:0:0:root:/root:/bin/bash
Chroot in again and hit 'passwd root' and you should be able to set a new password for root now.
I've done this when I've lost root password but not when the root user itself has been deleted. But these steps should work by and large.
Last edited by indeliblestamp; 07-07-2008 at 12:54 AM.
Reason: minor edits
How have you done it? Just removed these lines from files passwd and shadows? Or may be disabled it?
If you can boot in single user mode, it'll be possible to edit them again, or use command useradd.
If not, it could be recommended to reinstall the system. Especially, if you have made some other mistakes like that.
I suppose, there is no critical information on the box?
When the GRUB menu appears, hit any key to stop the countdown, "e" for edit, then select the kernel line and "e" for edit again. Add the work "single" (no quotes) at the end of the line, and then boot. You will be logged in as the root user with no password needed. Then set your password using the "passwd" command, and re-boot.
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,629
Rep:
Quote:
Originally Posted by pixellany
...You will be logged in as the root user with no password needed...
I didn't try this, but that looks like a wide open door to capture a system. Getting logged in as root with no password needed ... isn't that the dream of every hacker in existence? What am I overlooking?
I guess its the fact that you need physical access to the machine if you want to switch runlevels at boot time. If a bad guy is sitting in your house or office server room, your data is pretty much completely compromised anyway (he could just take the hard disk out, for instance).
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,629
Rep:
Quote:
Originally Posted by arungoodboy
...If a bad guy is sitting in your house or office server room...
Sure. But it also means any user in a firm can become root (if (s)he has physical access -- but nobody controls all situations). This is no problem for me, but were I administrator I think I'd like to disable that "feature".
Ya that's true. I dunno about Lilo but I think you can set a password in grub to prevent random people from fiddling with boot time arguments. Now if you forget that password too..
Sure. But it also means any user in a firm can become root (if (s)he has physical access -- but nobody controls all situations). This is no problem for me, but were I administrator I think I'd like to disable that "feature".
Thats why you only let certain people in the server room and/or have a bootloader password
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,629
Rep:
Quote:
Originally Posted by AceofSpades19
...have a bootloader password
That's an acceptable solution . There may always be situations, where access to the server room is not as restricted as designed, but a password for GRUB -- fine. Thanks all.
Another solution: Boot into "single-user" mode.
When the GRUB menu appears, hit any key to stop the countdown, "e" for edit, then select the kernel line and "e" for edit again. Add the work "single" (no quotes) at the end of the line, and then boot. You will be logged in as the root user with no password needed. Then set your password using the "passwd" command, and re-boot.
This may work for the Ubuntu's (haven't tried it yet) but I know on my Debian systems I am still prompt for a root passwd or Ctrl + D to continue.
When the GRUB menu appears, hit any key to stop the countdown, "e" for edit, then select the kernel line and "e" for edit again. Add the work "single" (no quotes) at the end of the line, and then boot. You will be logged in as the root user with no password needed. Then set your password using the "passwd" command, and re-boot.
Usually by default on RHEL, single user will prompt for root's password, added security so people can't login when they have physical access to gain root access.
The other way around this is to boot by adding this to the grub line: init=/bin/bash
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.