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.
- Real, Effective and Saved UserID in Linux
- How to Change the Mac Address in Kali Linux Using Macchanger?
- How to Change Root Password in Kali Linux?
- username Command in Linux With Examples
- Difference Between Arch Linux and Kali Linux
- Kali Linux - Password Cracking Tool
- Difference Between Ubuntu and Kali Linux
- How to Install Lazy Script in Kali Linux?
- Kali Linux Tools
- What is Vulnerability Scanning in Kali Linux?
- Introduction to Kali Linux
- How to Hack WPA/WPA2 WiFi Using Kali Linux?
- Kali Linux - File Management
- Kali Linux - Default Passwords
- Kali Linux - Crunch Utility
- How to Create Reverse Shells with Netcat in Kali Linux?
- Kali Linux - Terminal and Shell
- Kali Linux - Command Line Essentials
- Difference Between Fedora and Kali Linux
- Kali Linux - Exploitation Tools
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.