LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Steps to regain access (https://www.linuxquestions.org/questions/slackware-14/steps-to-regain-access-4175623436/)

nix84 02-09-2018 01:52 PM

Steps to regain access
 
Having forgotten my password I need to get access.
I tried the following set of instructions without success.
Can someone tell me where the instructions are not working and why and
how to fix?
1. Power on the PC
2. Boot the Installation CD.
3. Press: Enter-Key when asked about keymap
4. Login as: root
5. Now you are superuser!
TO DO IT:
6. If lacking which partition on which root resides, type fdisk -l
and check what is on each partition.
Presuming it is on /dev/sda2 for arguement sake.
7. mkdir test <OK>
8. mount /dev/sda2 test # Mount the root partition to a directory
???Why What purpose? [pwd showed test dir is on /, i.e. root]
9. chroot test # Change root directory to test <Doesn't work>
???why not working?? cuz of #8??
10. vi /etc/shadow # <?OK>
11. Note the root:<encryption number>:<ID>:0:::::
12. Delete ONLY the encryption number or replace it with: "" or blank or *
?Tried all, unless ? above a fixed this is not working
13. :wq Saves and closes the shadow file.
14.?umount test #?? Seems to be working but unsure
15. Take the LiveCD from the DVD/CD player
16. Reboot system.
17. Enter the slackware login as root with blank password also tried "", "*"
18. Change the password(s) with passwd
19. finish ^^
17 and on didn't work obviously, THANX appreciated! My notes are with "?".

Darth Vader 02-09-2018 01:59 PM

No need to mess with the installation CD. Believe or not, usually is enough to append on boot, to lilo entry command line:
Code:

Linux init=/bin/bash
(note that I used "Linux" as boot entry)

When the boot process finalize, you are directly logged in as root and you can reset your password or even mess with the system as you wish. BUT, before that, you should execute:
Code:

mount -n -o remount,rw /
I know, I know, Linux is super-secure... BUT that's unless the offender has physical access to computer. In this case, only the system encryption can save your ass. ;)

nix84 02-09-2018 03:27 PM

Not sure where the "Linux" should be entered?? Is there a "boot" prompt somewhere I dont recall. Probably cuz I don't have it handy to check right now.
What is the mount command, what does it do and when?
Would prefer to follow my notes if I can get them corrected, but thanks anyway will check later.

TracyTiger 02-09-2018 05:32 PM

Quote:

Originally Posted by nix84 (Post 5817882)
6. If lacking which partition on which root resides, type fdisk -l
and check what is on each partition.
Presuming it is on /dev/sda2 for arguement sake.
7. mkdir test <OK>
8. mount /dev/sda2 test # Mount the root partition to a directory
???Why What purpose? [pwd showed test dir is on /, i.e. root]
9. chroot test # Change root directory to test <Doesn't work>
???why not working?? cuz of #8??
10. vi /etc/shadow # <?OK>

If you mounted /dev/sda2 successfully on /test as read/write then you should be able to change your directory to /test/etc the then edit password (or shadow).

Try editing /test/etc/password and just remove the 'x' in the second field. I haven't done this for decades but I believe that should work. Once this is done I don't believe any edit is necessary for shadow.

No need for chroot.

bassmadrigal 02-12-2018 11:53 PM

Quote:

Originally Posted by nix84 (Post 5817914)
Not sure where the "Linux" should be entered?? Is there a "boot" prompt somewhere I dont recall. Probably cuz I don't have it handy to check right now.

This is done during the boot process... but the process depends on your bootloader. The default for Slackware is lilo, which will present you a screen to select your system to load, and at that point, I believe you can press *TAB* to allow you to enter your own startup command. Or you can edit your "appends" line in your bootloader's config file, which will add that for you automatically. Since you can't boot your computer now, you can use a Slackware install "disk" to boot your system and make any changes you need.

But to go to your original post, why didn't the chroot work? What errors did you get? If you did indeed mount your root partition, and that partition contained the required files, it should've been a nonevent to chroot. So, since it didn't work, I'm curious what your error was. That could give us the info to give you an idea on how to solve this. Your steps seem to be right. You should be able to boot the installer, mount the root partition, chroot the root partition, then run passwd for the root user (which would be the default user). Then reboot the system and you should have root access with the new password.

koloth 02-13-2018 04:58 AM

Let me try to clarify what the process you try to follow does:

Steps 1-5: Booting the system using the boot CD gives you a prompt - keep in mind the the / directory you login resides at is not your hard disk's one but the one created in memory by the boot CD. As a result altering any file would have absolutely to impact to your installed system. What you need to do is mount your disk and change YOUR files.

Steps 6-8: Mount your root partition as the test dir. now you can see and change your files. Keep in mind that your files reside in /test. for example your passwd file is :
/test/etc/passwd.

At this point my advice is to break with that process and do the following (I'm reusing where necessary) :
Quote:

vi /test/etc/shadow
Note the root:<encryption number>:<ID>:0:::::
Delete ONLY the encryption number or replace it with: "" or blank or *
:wq Saves and closes the shadow file.
Quote:

umount test
Take the LiveCD from the DVD/CD player
Reboot system.
Enter the slackware login as root with blank password also tried "", "*"
Change the password(s) with passwd
finish


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