How to Change the username or userID in Kali Linux?
Last Updated :
19 Sep, 2024
Kali Linux, a popular Linux distribution for penetration testing and ethical hacking, allows users to create a username during installation, automatically assigning a unique User ID (UID) to each user for identification. However, there are situations where you might need to change the username or user ID, such as when renaming accounts for clarity or security purposes.
Here, we'll show you how to efficiently modify usernames and user IDs using the powerful 'usermod' command in Kali Linux.
What is the 'usermod' Command?
The 'usermod' command in Linux is a tool used to modify user account details, including the username and User ID (UID). It is a part of the Linux user management utilities, which also include commands like 'useradd' and 'userdel'. The 'usermod' command allows system administrators to change account details, making it easier to update usernames and UIDs as needed without affecting the user’s data or permissions.
Understanding User ID and Username in Linux
But before changing the username or user ID we shall be aware of what is the user ID or username.
- User ID (UID): A unique identifier assigned to each user on a Linux system. It is used by the system to differentiate between users, even if they share the same username.
- Username: A human-readable identifier assigned to a user for login purposes.
User account details, including the UID, username, full name, default shell, and more, are stored in the '/etc/passwd' file. Meanwhile, password-related details like password hashes are stored in the '/etc/shadow' file.
Steps to Change the username or userID in Kali Linux
Let us look at the various steps to change the username in Kali Linux.
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
To change the username of an existing user, use the usermod command with the '-l' option:
usermod -l newusername oldusername
Replace the 'oldusername' with the name of the user you want to change.
- oldusername: The current username you want to change.
- newusername: The new username you wish to assign to 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.
- 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.
Conclusion
Changing usernames and User IDs in Kali Linux using the usermod command is a straightforward process that provides flexibility in managing user accounts. By following the steps outlined in this guide, you can efficiently modify usernames and UIDs without disrupting system functionality. Always verify your changes and ensure proper file ownership to maintain system integrity.
Similar Reads
How to Change Time in Kali Linux Kali Linux is a popular Debian-based Linux distribution used for pen-testing and ethical hacking. It is developed and maintained by an American cybersecurity firm, Offensive Security. Kali Linux comes pre-installed with various tools and software required for penetration testing and ethical hacking,
4 min read
How to Change the Mac Address in Kali Linux Using Macchanger Imagine your computer has a special ID card for connecting to the internet, called a MAC address. Itâs like a name tag that tells networks who you are. Sometimes, for privacy or testing, you might want to change this ID. If youâre using Kali Linux, a system made for people who study security and hac
2 min read
How to Change The Primary Group of a User in Linux? In the field of Linux system administration, learning the modification of the primary group is essential. In this article, we are going to deliver concise details about user groups and how to manage them. What is a Primary Group?In Linux, every user is associated with a primary group. The primary gr
7 min read
How to add User in Linux | useradd Command useradd is a command in Linux that is used to add user accounts to your system. It is just a symbolic link to adduser command in Linux and the difference between both of them is that useradd is a native binary compiled with the system whereas adduser is a Perl script that uses useradd binary in the
5 min read
How to Delete User in Linux | userdel Command Managing user accounts is an essential aspect of Linux system administration. Understanding how to delete a user in Linux is crucial, whether you need to remove an unused account, revoke access for a departing employee, or clean up your system for security reasons. Here, we will explore the 'userdel
5 min read