Friday, May 17, 2024
18
rated 0 times [  18] [ 0]  / answers: 1 / hits: 6423  / 3 Years ago, fri, september 10, 2021, 11:44:41

Here is what I have done:




  1. Change a username in the last line: tiny to abc




    • tiny@tty7:~$ sudo vim /etc/passwd

    • Change this:

      tiny:x:1000:1000:tiny,,,:/home/tiny:/bin/bash

      to this:

      abc:x:1000:1000:tiny,,,:/home/tiny:/bin/bash


  2. tiny@tty7:~$ sudo vim /etc/shadow




    • it shows: [sudo] passwork for abc:


    • I didn't change my password but it can't login root!


    • I type Ctrl+Alt+F1 to tty1 but neither tiny or abc can't login with my password





and I try to look at ls ~ -la, here it shows like this:



drwxr-xr-x 28 abc tiny 4096 Apr 6 03:04 .



How can I login root? and why the user name in prompt tiny@tty7 still be tiny while in sudo it show the abc's password?


More From » command-line

 Answers
7

The reason you got stuck after your edit is that the /etc/shadow file contained an entry for the password of tiny but no entry for abc, whereas the /etc/passwd file contained an entry for abc and not for tiny. When sudo looked, it identified you correctly (according to the password file) as abc based on the UID of the process you were running, but when it looked to compare what you entered as your password with the encrypted (hashed) password stored in /etc/shadow, it couldn't find an entry for abc, so it had to report the failure.



As shaddy said in his answer, don't edit the password or shadow files by hand. If you must break the rule, then edit both in a single invocation of vim, and don't exit from vim until you've proved that the changes are sane enough to work by using another terminal window, and do save backup copies of the files before you start hacking them, and do reconsider why you're breaking the rules in the first place, because it probably isn't a good idea.


[#20642] Sunday, September 12, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
azaaburge

Total Points: 266
Total Questions: 85
Total Answers: 109

Location: Djibouti
Member since Sat, Oct 29, 2022
2 Years ago
azaaburge questions
Thu, Jun 2, 22, 23:28, 2 Years ago
Sun, Oct 17, 21, 05:20, 3 Years ago
Fri, Jun 25, 21, 16:22, 3 Years ago
;