Want to change consumer accounts in Linux? That is the command for you


Trevor Williams/DigitalVision by way of Getty

Comply with ZDNET: Add us as a most well-liked 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 definitely is useful, particularly given what it could do.

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

1. Change consumer particulars

Once you create a Linux consumer with the adduser command, you may embrace sure particulars to go together with the brand new consumer (similar to full title, workplace and residential cellphone numbers, and different data, which can be utilized as an outline. After you’ve got created the consumer, the one option to change or add such data 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 concern the command:

sudo usermod -c “INFORMATION” USER

Additionally: 5 surprisingly productive issues you are able to do with the Linux terminal

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

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

2. Change a username

You can even change a username. Earlier than you do that, know that it doesn’t change the consumer’s residence 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 seem like this:

sudo usermod -l samantha sam

The -l choice is for the login title.

3. Rename a house listing

After you modify a username, you may additionally wish to rename the consumer’s residence listing. Earlier than you do that, it’s essential to be certain that the consumer is logged out; in any other case, it may wreak havoc on their account (or their knowledge). You additionally have to ensure that the consumer’s knowledge is added to the brand new residence listing (in any other case, the consumer winds up with an empty residence). 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 /residence/samantha -m sam

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

Additionally: There is a new coolest Linux distribution able to wow you 

4. Lock and unlock a consumer’s account

There could also be occasions when you should lock a consumer out of their account (and later enable them again in). This may very well 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 concern the command:

sudo usermod -U USER

The place USER is the consumer account.

6. Change a consumer’s account expiry date

Do you know you may expire a consumer account in Linux? For instance you might have a temp worker whose contract ends on October 31, 2025. If you wish to set the particular person’s consumer account to run out on that date (as an alternative of getting to recollect it when the date arrives), you should utilize the expiry function 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 gaggle (or teams)

I’ve had to make use of this function so many occasions. For instance, I exploit 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 gaggle that shall be utilized by a number of accounts to entry a particular folder. For instance you’ve got created the editorial group and wish to add sam to it. The command for that may be:

sudo usermod -aG editorial sam

Additionally: 7 Linux terminal fundamentals each newbie ought to study first – and why

8. Modify a consumer’s residence listing

In case you’ve renamed a consumer account, you may discover their residence listing remains to be listed as the unique username. If you want to rename the consumer’s residence listing (to keep away from confusion), usermod has your again. Earlier than you do that, nevertheless, it is necessary that you just make certain the consumer is logged out of their account (in any other case, it may trigger critical issues).

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

sudo usermod -d /residence/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 may change a consumer’s shell. For instance you wish to change samantha’s shell from bash to zsh. To try this, you need to first make certain the brand new shell is definitely put in with the command:

cat /and so forth/shells

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

sudo usermod -s /bin/SHELL samantha

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





Source link

Related articles

Bitcoin Worth Watch: Bulls Wrestle to Maintain Floor After Sharp Reversal

Simply after 8 a.m., bitcoin traded between $111,760 and $112,091 within the final hour as volatility remained contained regardless of bearish indicators throughout a number of timeframes. The asset’s market capitalization stood at...

Equinor prepares to begin delayed deepwater undertaking offshore Brazil

(Bloomberg) – Equinor ASA says it might quickly begin producing at a big deepwater oil subject off the coast of Brazil after struggling delays at a undertaking that’s essential for its development technique.  ...

Wall Avenue Week Forward | Looking for Alpha

Pay attention on the go! A each day podcast of Wall Avenue Breakfast will likely be obtainable by 8:00 a.m. on Looking for Alpha, iTunes, Spotify. Looking for Alpha Information Quiz Up...

Get a Microsoft Workplace Professional 2021 lifetime license and a coaching bundle for simply $40

TL;DR: Seize Microsoft Workplace Professional 2021 for Home windows plus a whole Microsoft coaching bundle for simply $39.97 (MSRP: $239.99) — a lifetime license and 25 hours of coaching in a single bundle. Proudly owning Microsoft Workplace Professional 2021...

IG, Pepperstone, B2PRIME and Extra: Government Strikes of the Week

IG Onboards New Group CTOIG Group (LON: IGG) introduced that David Perry has been appointed as the brand new Group Chief Know-how Officer. “His expertise and management shall be instrumental as we proceed...
spot_img

Latest articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

WP2Social Auto Publish Powered By : XYZScripts.com