How to Change the username or userID in Kali Linux?
Kali Linux allows us to enter the username while installing it and it assigns the username a unique user id to identify the user and it assigns the id itself. Now there come situations when we have to change the username or user id. This can be done easily with the help of usermod command.
But before change the username or user id we shall be aware of what is the user id or username. The details of a user such as userID, username, the complete name of the user, default shell, etc. are stored in a file which is /etc/passwd and all the password related details like the hash of the password is stored in /etc/shadow file. To get the userid or other details of a user we read passwd file and even in that file we read the line which has the details of the user in it. In order to do that we use the following command.
1. To get the user id of a user
cat /etc/passwd | grep oldusername
Replace the oldusername with the name of the user you want to use.
This will display us a few details of the user along with the userid.
2. To change the Username. We use usermod command along with -l parameter in order to change the username of a particular user.
usermod -l newusername oldusername
Replace the oldusername with the name of the user you want to change and the newusername with the new name of the user.
This command will change the username of the oldusername to the newusername but will not change the files and userID of the user.
3. To change the UserID we use usermod command along with -u parameter in order to change the userid of a particular user.
usermod -u 1234 newusername
Replace the newusername with the username you want to change the id of. And Replace 1234 with the id you want to set for the user.
This command will change the userid of the user from the default one to 1234.
Please Login to comment...