You can do this by deleting x
in / etc / passwd
.
$ vi /etc/passwd
root:x:0:0:root:/root:/bin/bash
From left to right, the user name, password, user ID, group ID, comment, home directory, and login shell.
The password here is the second x
from the left. This means an encrypted password. I'm scared if I can see it.
By deleting this, you will be able to log in without a password.
- root:x:0:0:root:/root:/bin/bash
↓
+ root::0:0:root:/root:/bin/bash
Let's log in from the hoge user
[hoge@111111111111 ~]$ su -
[root@111111111111 ~]$
I was able to become root without being asked for my password!
By the way, under normal circumstances, only the root user or someone with sudo privileges can edit / etc / passwd
.