19.2 C
New York
Tuesday, September 16, 2025

Buy now

Need to modify user accounts in Linux? This is the command for you

Comply with ZDNET: Add us as a most popular supply on Google.


The usermod command is brief for consumer modification, and, because the title implies, permits you to modify varied features of a consumer account. 

For a Linux administrator, this command is essential. For Linux customers, the command most actually is useful, particularly given what it will possibly do.

Let’s dive down this rabbit gap and see what’s what with the Linux usermod command.

1. Change consumer particulars

While you create a Linux consumer with the adduser command, you possibly can embrace sure particulars to associate with the brand new consumer (reminiscent of full title, workplace and residential telephone numbers, and different info, which can be utilized as an outline. After you’ve got created the consumer, the one option to change or add such info is by way of the usermod command. Say, as an example, you wish to add a remark for a consumer. To try this, you’d problem the command:

sudo usermod -c “INFORMATION” USER

The place INFORMATION is what you wish to add, and USER is the consumer account you wish to change.

This may be helpful in case you have two customers with the identical first title and also you wish to differentiate them of their consumer info. 

See also  Oracle invests $40 billion in Nvidia chips to build one of the world's largest data centers

2. Change a username

You can too change a username. Earlier than you do that, know that it doesn’t change the consumer’s dwelling listing title. So if I’ve the consumer sam and I wish to change it to samantha, usermod is there to assist me. Such a command would appear like this:

sudo usermod -l samantha sam

The -l choice is for the login title.

3. Rename a house listing

After you alter a username, you may also wish to rename the consumer’s dwelling listing. Earlier than you do that, you should be sure that the consumer is logged out; in any other case, it might wreak havoc on their account (or their information). You additionally have to make it possible for the consumer’s information is added to the brand new dwelling listing (in any other case, the consumer winds up with an empty dwelling). To alter a listing title (and add the information), you’d use a command like this (sticking with our sam/samantha instance):

sudo usermod -d /dwelling/samantha -m sam

The -d choice units the brand new dwelling listing path, and the -m choice strikes the information.

4. Lock and unlock a consumer’s account

There could also be instances when it’s good to lock a consumer out of their account (and later permit them again in). This could possibly be used for short-term staff or grounded kids. To lock a consumer account, the command could be:

sudo usermod -L USER

The place USER is the username to which the lock applies.

To unlock the account, you’d problem the command:

sudo usermod -U USER

The place USER is the consumer account.

See also  Apple iPhone 17 event live blog: The biggest announcements we're expecting on Tuesday

6. Change a consumer’s account expiry date

Do you know you possibly can expire a consumer account in Linux? As an instance you’ve gotten a temp worker whose contract ends on October 31, 2025. If you wish to set the individual’s consumer account to run out on that date (as a substitute of getting to recollect it when the date arrives), you should utilize the expiry characteristic of usermod like so:

sudo usermod -e 2025-10-31 USER

The place USER is the consumer account title.

7. Add a consumer to a bunch (or teams)

I’ve had to make use of this characteristic so many instances. For instance, I take advantage of Docker rather a lot, and once I set up it, I’ve so as to add customers to the group (in any other case it will not work for them with out utilizing sudo, which might result in safety points). You may need additionally created a bunch that will probably be utilized by a number of accounts to entry a particular folder. As an instance you’ve got created the editorial group and wish to add sam to it. The command for that might be:

sudo usermod -aG editorial sam

8. Modify a consumer’s dwelling listing

If you happen to’ve renamed a consumer account, you may discover their dwelling listing continues to be listed as the unique username. If you need to rename the consumer’s dwelling listing (to keep away from confusion), usermod has your again. Earlier than you do that, nevertheless, it is vital that you just be sure the consumer is logged out of their account (in any other case, it might trigger severe issues).

See also  3D mood board and marketplace MattoBoard picks up $2M to launch AI visual search

To alter the title of a consumer’s dwelling listing, the command could be:

sudo usermod -d /dwelling/NEWNAME OLDNAME

The place NEWNAME is the brand new title for the listing and OLDNAME is the present title.

9. Change a consumer’s shell

Chances are high fairly slim that you’re going to ever want to do that, however you possibly can change a consumer’s shell. As an instance you wish to change samantha’s shell from bash to zsh. To try this, it is best to first be sure the brand new shell is definitely put in with the command:

cat /and so on/shells

If zsh is listed, you possibly can change it for samantha with the next command:

sudo usermod -s /bin/SHELL samantha

Need to comply with my work? Add ZDNET as a trusted supply on Google.

Supply hyperlink

Related Articles

Leave a Reply

Please enter your comment!
Please enter your name here

Latest Articles