Tips on how to Change a Username and Different Account Particulars on Linux

Linux is a multi-user operating system. And with that function comes the responsibility for managing every user in the system. The administrator must ensure that each user has the correct permissions, unique user IDs, unique usernames, and so on.

But what if you want to change the information associated with a specific user? Does Linux allow anyone to easily change such sensitive details? The usermod command is the answer to all of these questions.

This article shows how to change your username on Linux, along with detailed instructions on how to change a user's user ID and home directory.

Change a username on Linux

On Linux, the / etc / passwd file saves the information associated with the users. Although you can change the user details directly by editing the passwd file, it is not recommended as it can cause various problems on your system.

You can use the usermod utility provided by Linux to perform user management and moderation-related operations. You can even use the usermod command to change a user's username on Linux.

Note that you must have access to a superuser account to successfully run these commands. If you don't have permission, you can ask your system administrator to add you to the Sudoers list.

To change the username, use the -l Flag with Usermod:

usermod -l newusername oldusername

For example, to change the username of the user "makeuseof" to "muo":

usermod -l muo makeuseof

Rename the home folder

Changing the username on Linux with the above command does not change the home directory of that particular user. Use the -d Flag if you want the home folder to reflect changes made to the username.

To rename the user's home directory muo:

usermod -d / home / muo -m muo

To check if the above command works, go to the home directory and find the folder called muo.

Assign a new user ID to a user

Aside from changing the username, you can also use the usermod command to assign a new and unique UID to each user. The UID is a non-negative integer that starts at zero. UIDs in the range 0-99 are reserved for system users.

To change the user ID on Linux with usermod:

usermod -u uid username

…Where uid is the user ID that you want to assign to the user named Username.

If you change the UID, the system will add the new UID as the owner of all files and folders contained in the. available /At home Directory of this particular user.

Note that the user has the owner details of all files outside of the /At home Directory.

Related: How to Grant Administrator Privilege to a User on Linux

Change a user's display name

The username and user ID are important to identify a specific user in the system. Aside from these two, Linux also stores additional "finger information" related to users in the / etc / passwd File. This information includes the user's display name, office phone, and work phone.

While users have a full choice of whether or not to provide such information, on Linux they can change or remove this information at any time.

You can change the display name of your account with either usermod or the chfn command.

Using the usermod command

Specify that -c Flag together with the usermod command to change the display name:

usermod -c "first last" username

For example, if you want to change the user's display name muo:

usermod -c "Make UseOf" muo

Using the chfn command

Changing the display name using the chfn command is easy:

sudo chfn -f "first last" username

How to change the user's display name make use of:

sudo chfn -f "Make UseOf"

Managing user information on Linux

With Linux offering so many options when it comes to user management, the need for a special user with elevated privileges is obvious. Because of this, every Linux system has a root user or superuser who controls and monitors the activities of other users on the system.

To add an extra layer of security and ensure that every user is isolated from the rest, Linux offers the option of adding a password to your account. If you've already set a weak password without thinking twice, it is a good idea to change it to keep your account more secure.

How to change your Linux password

Do you need to change your Linux password? Here is everything you need to know about how to reset a password on Linux.

Continue reading

About the author

Deepesh Sharma
(71 articles published)

Deepesh is Junior Editor for Linux at MUO. He has been writing informational content on the Internet for over 3 years. In his spare time he enjoys writing, listening to music and playing the guitar.

From Deepesh Sharma

Subscribe to our newsletter

Subscribe to our newsletter for tech tips, reviews, free e-books, and exclusive offers!

One more step …!

Please confirm your email address in the email we just sent you.

Expand to read the full story

Leave a Reply

Your email address will not be published. Required fields are marked *