Change Linux username
非 root 用户,所以会用到 sudo, 使用 distribution 为 Ubuntu22.04-amd64
log in to a user other than target user
Change home directory:
sudo mv /home/target_old_username /home/target_new_usernameChange
/etc/passwd:sudo vim /etc/passwdChange
/etc/shadow:sudo vim /etc/shadowChange
/etc/group:sudo vim /etc/group
附上 chatGPT 的相关回答
/etc/passwd: This file contains information about all the system users. You need to hcange the username in the first field and the home directory in the sixth field.
/etc/shadow: This file contains password information about all the system users. You need to change the username in the first field and the home directory in the first field.
/etc/group: This file contains information about all the system groups. You need to change the old username to the new one in all the lines where it appears.