16

My friend had put Linux Mint 17.3 Cinnamon 64 bit on my computer. Well, I forgot the user name, so I did a search on the Net for "forgot username linux" and came here.

I got the suggestion to hit 'e' at the 1st item in GRUB which I did. The next part of the suggestion said to look for a line that started with KERNAL. Now here is where it gets interesting. I didn't find a line with KERNAL in it. However, I did find a line that started with LINUX.

The full unedited line reads:

linux        /vmlinuz-3.19.0-32-generic root=UUID=0c031f3a-81ae-4c33-06cc--c82a855736d1 ro  quiet splash $vt_handoff

The suggestion then said to look and edit splash quiet to single. Now if you notice above it says quiet splash instead of splash quiet. So I figured I would edit the quiet splash to single.

Now it's asking for a root password. Can anyone help? I suppose I'll need a Live CD.

  • 30
    You need to pay attention to what you read. It wouldn't ever read “KERNAL” because that's not how the word is spelled. (If you really found a tutorial that says “KERNAL”, ditch it.) Mind you, it wouldn't say “KERNEL” either, so if you found a tutorial that says that, you should probably ditch it as well. – Gilles Nov 19 '17 at 20:52
  • 9
    Boot on a live cd, mount the harddisk and locate /etc/password. You will be able to see your username there. – Thorbjørn Ravn Andersen Nov 19 '17 at 23:56
  • 14
    @ThorbjørnRavnAndersen Isn't that /etc/passwd? – Angew Nov 20 '17 at 9:11
  • 5
    @Angew Typically, yes. (This is one reason why answers in comments is almost universally considered poor form. There is no easy way to fix that.) – a CVn Nov 20 '17 at 10:41
  • 3
    Errrm, have you asked your friend, who installed it for you ? – Mawg Nov 20 '17 at 13:12
35

Exactly what happens when you replace quiet splash or splash quiet (the order doesn't matter) by single depends on the distribution. Most distributions will ask for a root password.

If you don't remember the root password, or you just want to boot in the most minimal way, you can replace quiet splash (and $vt_handoff, for that matter) by init=/bin/bash. The line should look like

linux /vmlinuz-… root=… ro init=/bin/bash

The amount of whitespace between the parts doesn't matter, just leave at least one space wherever there was one before. The parts that I replaced by above do matter, you must leave what was there before. Remove everything except for the leading word linux, the word after that, root=… and ro, and add init=/bin/bash.

When you boot, you'll get a bash command line, running as root. When you have physical access, the only security that could prevent you from getting in is encryption. (If your system has full-disk encryption, you will need to enter the encryption password.)

At this command line, run the following commands:

mount -o remount,rw /
mount /proc

Then you can view and modify the user database. The main user database file is /etc/passwd. It contains user names (for both physical users and system accounts), but passwords are in a different file /etc/shadow. Both files are human-readable up to a point. You cannot recover passwords though; if you've forgotten a password, all you can do is change it.

The following command lists accounts that have a password:

grep -v ':[*!]:' /etc/shadow

(Type it carefully, it's pretty sensitive to the exact punctuation.) The first part of each line, before the first : sign, is the username.

If you want to change the password for an account, run

passwd rob

where rob is the username.

Once you've noted the username and changed the password if desired, run

mount -o remount,ro /
reboot
  • 6
    OP has forgot their username, but don't say anything about the password. For that use case, just cat /etc/passwd will likely be enough; no need to remount the root file system read-write, or run through passwd. Basically, if OP knows their password but has somehow forgot their username, everything from "At this command line, run..." onward can pretty much be replaced by "run cat /etc/passwd, look for a reasonable name in the first field, then run reboot and try that name for login" (expanded upon with some on how to do that because I'm running out of space in the margin). – a CVn Nov 20 '17 at 10:40
  • Also, on some systems mount will need an -n switch. – rackandboneman Nov 20 '17 at 22:35
14

Follow these steps:

  1. boot from a live cd
  2. open a terminal in the live environment
  3. run command lsblk, you will get a list of drives and partitions. One of these should be the root partition in which you installed linux mint (sdxn, x being a letter, n being a number?).
  4. mount the root partition on an empty directory
  5. open etc/passwd file in the mounted partition. this should contain your username in one of the lines, you should be able to identify it.
0

http://www.microhowto.info/howto/reset_a_forgotten_root_password_using_a_live_distribution.html

That article seems to cover it well. Yes, you need a live cd.

In the article he gives you an alternate, and he notes, very risky method, of directly editing the password file. Follow his advice and do not try that.

it's not worth copying over verbatim his method, because it's well explained and complete, as well as being as verbose as necessary to do all the steps, with the code examples for each step.

It's not hard, just follow the directions closely.

Basically you boot into the live cd on the system you want to update, then you mount the root file system on the system to be updated, chroot to that mount point, then use passwd to change the password. It may sound intimidating, but really it's not. Note that some systems have /mnt, and others have /media, as defaults, just use which ever your live cd comes with when creating the mount directory, that does not matter at all, it's a just a path you are going to use when you chroot into the system you are trying to update the password on.

Many live cds, by the way, will give you root with this command (I think that's it, it's been a while, heh):

sudo su -

You will need to be root to do those actions on the live cd, so just check the live cd docs on how it allows the root user to login to the shell on the live cd.

  • Thanks to all of you. I'll let know what happens. One more question: Was it right for me to start a new thread or should I have used another one? – Rob Ricci Nov 19 '17 at 20:43
  • It depends on if the same question has been asked verbatim or not. I didn't search, I should have. But I'd say, if you searched, or gave it a good try, and didn't find it, then tacking onto an existing thread is probably inappropriate. Mods can determine if it's duplicated or not. I liked your question, because while I never lose my passwords, it was nice to see how easy it would be to recover them were I to lose them, so on my part, thanks for asking the question. – Lizardx Nov 19 '17 at 20:51

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.