LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Root Account Disabled (not smart) Can not root LOGIN (https://www.linuxquestions.org/questions/slackware-14/root-account-disabled-not-smart-can-not-root-login-736439/)

mitchellray 06-29-2009 11:39 AM

Root Account Disabled (not smart) Can not root LOGIN
 
Hello,
I mistakenly disabled the root account in kuser and now can not log in as root.
I did this when I repeatedly received an error when trying to log in as su saying that 'could not connect to x'.

How can I regain login access with my root password? or have I finally made the BIG error?
Mitchell

willysr 06-29-2009 12:05 PM

you can try to use Slackware CD 1 to boot the system and change the entries in /etc/passwd after you mounted the / (root) partition and chroot to it.

mitchellray 06-29-2009 12:19 PM

Root Account Disabled; Can not root LOGIN
 
Hello willysr,
I installed slackware 12.2 from iso.
Could you please advise step by step how to do the boot and mounting and the change of status on the root account.
I am not clear on if I am to unlock the password or to create a new root user account.
Thank you.
Mitchell

Woodsman 06-29-2009 12:47 PM

First try something simple. Log in as normal user, then start Kuser. You'll have to type root's password. If you are lucky and can start Kuser, then clear the 'Account disabled' check box in the root account.

If you are using GRUB as a boot loader, you could try booting into run level 1 (single user mode). Manually add 'init 1' to the boot options. If you can log in at that point, type 'passwd' to change the root password.

If you are using Lilo then proceed with Willy's solution. When you boot with the installation CD/DVD, don't run setup. Just log in. Then type:

mkdir /hd
mount /dev/hda(x) /hd [You have to know the partition number in place of (x)]

With the installation CD/DVD you have to use vi as a text editor, so be sure to know the basics of vi (:w, :q, insert, Esc).

After mounting the root partition, type:

vi /hd/etc/passwd

Somewhere in /etc/passwd, usually as the very first line, you should see something like this:

root:x:0:0::/root:/bin/bash

Notice the colons, which is why you have to understand the colon syntax with vi. You have to be in text insert mode before typing the colons, otherwise vi interprets the colon as a command.

Also notice that no password is present in /etc/passwd. That is because the password is stored in /etc/shadow. But you need an entry in /etc/passwd to enable the root account. Restoring that entry might be all you need.

If you need to edit /etc/shadow, here is a nice introduction to that file: Understanding /etc/shadow file . You might need to delete the encrypted password before trying to run the passwd command.

Yes, there is a passwd command as well as a passwd text file in /etc. :)

gegechris99 06-29-2009 02:29 PM

Quote:

Originally Posted by mitchellray (Post 3590309)
I installed slackware 12.2 from iso.

If you do not have Slackware CD1, then boot with any GNU/linux LiveCD and mount the Slackware "/" partition. After that, just follow Woodsman's instructions.

mitchellray 06-29-2009 06:30 PM

Root Account Disabled; Can not root LOGIN
 
Thank you Woodsman and gegechris99.
I am using lilo for Slackware 12.2 and also chainloading Fedora10.
This is going to require a lot of new learning.
I will begin with the reading and update my progress on this thread.

I can not log in to the KUser application. However, interestingly, I can open it as a normal user after running a 'find file'. However, when I try to 'ok' the change of account status (for any account, including root), I receive the error messages - "cannot open file /etc/passwd.bak for writing" and "Can't create back up file for /etc/passwd".

Are there any pitfalls (beyond what I have already done) that I should beware of so that I do not have to re-install the entire Slackware again?
Mitchell

Woodsman 06-29-2009 07:08 PM

Quote:

I receive the error messages - "cannot open file /etc/passwd.bak for writing" and "Can't create back up file for /etc/passwd".
Those are interesting messages. As normal user, can you see the files /etc/passwd and /etc/passwd.bak? What are the permissions on the files? They should be 644 (rw-r--r--) or at least 600 (rw-------).

Then again, perhaps the messages are related only to the fact that you are trying to modify those files as a normal user, who doesn't have permissions to modify those files.

Quote:

Are there any pitfalls (beyond what I have already done) that I should beware of so that I do not have to re-install the entire Slackware again?
Measure twice, cut once. :)

bgeddy 06-29-2009 08:13 PM

This should be quite easy to fix. Follow Woodsman's instructions to boot with the install disk and mount the Slackware parition. Then edit the /hd/etc/shadow file and look for the entry starting "root:!" it should have the exclamation mark here to mark logins as disabled. Just delete the exclamation and save the file then root should be able to login when you reboot your Slackware.

mitchellray 06-29-2009 11:05 PM

Root Account Disabled; Can not root LOGIN
 
Hello Woodsman,
I am able to read /etc/passwd, but not /etc/passwd.bak nor /etc/shadow.
In /etc/passwd I have 'root:x:0:0::/root:/bin/bash'.
It looks like what you posted above.

Thank you to all for taking time out to assist me.
I will try to follow your directions.
I have only gone through the Slackware install process once and am not confident about the directions regarding 'mounting' and then entering the /etc/passwd file to make changes.
Once I begin the process, in case of error, I will be left without any means of re-contacting this board (short of starting from scratch) -for further assistance.
Mitchell

Woodsman 06-29-2009 11:44 PM

Quote:

It looks like what you posted above.
Then the account is not deleted. Sounds like the problem probably is the password being disabled. Follow bgeddy's solution just above.

Do know that when you delete the exclamations mark (there might be two), the root account then will have no password when you boot into Slackware. After logging in as root, run the passwd command to set a new password.

bgeddy 06-30-2009 07:06 AM

Quote:

I have only gone through the Slackware install process once and am not confident about the directions regarding 'mounting' and then entering the /etc/passwd file to make changes.
Well you should learn about mounting things as it not hard and a basic function of Linux systems. I'll give a step by step automated way of doing this - I really can't make this any easier !

1) Boot to the Slackware install disk.

You have to know the partition number in place of (x) for this next step - also the partition may be called sd(x) where (x) is the partition number. If you are unsure of partition names or numbers run "fdisk -l" to show them. Next we mount the Slackware partition on the hard disk to a directory "/hd" in the install directory.

2) Run this:
Code:

mkdir /hd
mount /dev/hda(x) /hd

3) Run this :
Code:

sed -i 's/root\:\!/root\:/' /hd/etc/shadow
4) Reboot to Slackware. Login as root.

Here you are using a utility "sed" to search and replace the disabled root login part of the file with a "login enabled" setting.

mitchellray 06-30-2009 12:39 PM

Root Account Disabled; Can not root LOGIN - RESOLVED
 
Hello,
Thank you for the rescue Woodsman, bgeddy, willysr and gegechris99.

I booted with the Slackware12.2 iso from dvd.
I logged in as root.
I did the
mkdir /hd
mount /dev/hda(x) /hd
vi /hd/etc/shadow
I removed the '!!' after the root in the entry.
I 'esc' ':wq'.
I rebooted normally and the system entered run level 4 to login.
I logged in as root with my original password and it succeeded. I did not have to do a new password setup.

I opened KUser to find that the root account 'Account disabled' toggle is now in the off position. The account is enabled.

With community help, this os, Slackware12.2, has been running without need of reloading for longer than any other os I have used.
I am very happy that it has been preserved again.
Thanks.
Mitchell

Woodsman 06-30-2009 12:52 PM

Quote:

Thanks.
As younger folks today would say: Woot!

As us older folks might say: Far out! Out of sight! Groovy! Nifty! :D


All times are GMT -5. The time now is 01:28 AM.