How to Change a Username and Other Account Details on Linux
If you are a Linux user, then you probably have an account with a unique username that you use to log in to your system. However, sometimes you may need to change your username or other account details for security reasons or because you simply want a new username. In this article, we will guide you through the process of how to change a username and other account details on Linux.
Before we start, it is important to note that you need to have administrative privileges to change account details on Linux. If you are not the administrator of the system, you won’t be able to make any changes.
Change Username
Changing your username on Linux is a simple process that can be done using the `usermod` command.
- Open a terminal window by pressing `Ctrl+Alt+T`.
- Type the following command to change the username:
`sudo usermod -l new_username old_username`
Replace “new_username” with your desired new username and “old_username” with your current username.
- You may also want to change the home directory name to match the new username. To do this, type the following command:
`sudo usermod -d /home/new_username -m new_username`
This command will move your old home directory to the new one with the new username.
Change User ID (UID)
Every user on Linux has a unique identifier called the User ID (UID). If you need to change your UID for security purposes, follow these steps:
- Open a terminal window by pressing `Ctrl+Alt+T`.
- Type the following command to change your UID:
`sudo usermod -u new_UID username`
Replace “new_UID” with a new UID number and “username” with your current username.
Change Group ID (GID)
Every user on Linux has a default group that they belong to called the Primary Group. The Primary Group also has a unique identifier called Group ID (GID). To change your Primary Group ID, follow these steps:
- Open a terminal window by pressing `Ctrl+Alt+T`.
- Type the following command to change your Primary Group ID:
`sudo usermod -g new_GID username`
Replace “new_GID” with a new GID number and “username” with your current username.
Change Password
Changing your password on Linux is very easy. Follow these steps:
- Open a terminal window by pressing `Ctrl+Alt+T`.
- Type the following command to change your password:
`passwd`
- You will be prompted to enter your old password and then your new password twice.
Change User Information
You can also change a user’s information using the `chfn` command. Follow these steps:
- Open a terminal window by pressing `Ctrl+Alt+T`.
- Type the following command to change your user’s information:
`sudo chfn username`
- Enter the new information when prompted.