Skip to main content
News Directory 3
  • Business
  • Entertainment
  • Health
  • News
  • Sports
  • Tech
  • World
Menu
  • Business
  • Entertainment
  • Health
  • News
  • Sports
  • Tech
  • World
Linux User Account Modification Commands - News Directory 3

Linux User Account Modification Commands

September 16, 2025 Lisa Park Tech
News Context
At a glance
  • Okay, here's a breakdown of teh usermod commands explained in the provided text, categorized for⁣ easy reference.
  • The usermod command is used to modify user account information in Linux.
  • * Command: sudo usermod -l NEW_USERNAME OLD_USERNAME * Explanation: Changes the username from OLD_USERNAME to NEW_USERNAME.
Original source: zdnet.com

Okay, here’s a breakdown of teh usermod commands explained in the provided text, categorized for⁣ easy reference. I’ll also add some notes on potential issues and best practices.

usermod Command Summary (from the text)

The usermod command is used to modify user account information in Linux. It requires sudo privileges because it ⁤alters system-level settings.

1. Change a User’s⁣ Login Name

* Command: sudo usermod -l NEW_USERNAME OLD_USERNAME

* Explanation: Changes the username from OLD_USERNAME to NEW_USERNAME.
* ⁣ Vital: The user must not be logged in when⁣ you change the username.

2. Change a⁣ User’s Full⁤ Name (GECOS field)

* ⁢ ⁤ Command: sudo usermod -c "New Full Name" USERNAME

* Explanation: Updates the user’s full name, which is stored in the ‍GECOS field.⁢ This is often ⁣used for descriptive information.

3.⁤ Change a User’s UID‍ (User ID)

* Command: sudo usermod -u NEW_UID USERNAME

* explanation: Changes the user’s unique numerical ID.
* Important: Be ‍ extremely careful with this. ⁤ UIDs must be unique. Changing a UID can cause file ownership issues if not done correctly. Avoid changing UIDs unless absolutely necessary.

4. Change a User’s GID (Group ID)

* Command: sudo usermod -g NEW_GID USERNAME

* ⁤ Explanation: Changes the user’s primary group. The NEW_GID must be an existing group ID.

5. Lock/Unlock a User Account

* Lock: sudo usermod -L USER (Locks the account, preventing login. Password is encrypted with an exclamation ‍mark.)
* Unlock: sudo usermod -U USER (Unlocks⁣ the account, restoring⁤ login ability.)
* Use Case: Useful for temporarily disabling access (e.g., for temporary employees or disciplinary action).

6.Change a User’s Account Expiry Date

* Command: sudo usermod -e YYYY-MM-DD USER

* explanation: Sets an expiration date for the account. After this date, the user will not be able to log in.
* Example: sudo usermod -e 2025-10-31 USER

7. Add a User to a Group (or Groups)

* Command: sudo usermod -aG GROUPNAME USERNAME

* ‍ Explanation: Adds the user to the specified group(s).The -aG option ⁣is crucial; -a means “append” and -G specifies the group(s). Without -a, it replaces the user’s existing supplementary groups.
* Example: sudo usermod -aG editorial sam

8. Modify a user’s Home Directory

* Command: sudo usermod -d /home/NEWNAME OLDNAME

* Explanation: Changes the user’s home ⁢directory.
* ⁤ Critically important: ‍ The user must be logged out. You may also need to move the contents of the old home directory to the new one (using mv) and update file ownership.

9. Change⁤ a User’s Shell

*‍ Check Available shells: cat /etc/shells (This lists the valid shells on the system.)
* Command: sudo usermod -s /path/to/new/shell USERNAME

* Explanation: Changes the user’s login shell.
*⁣ Example: sudo usermod -s /bin/zsh samantha

General Notes & Best Practices:

* ⁣ sudo: Almost all usermod commands ⁢require sudo because they modify system-level user account information.
* Backup: Before making significant changes (especially UID/GID), consider backing⁤ up yoru user account information (e.g.,/etc/passwd,/etc/group,/etc/shadow).
* Testing: ‍ if possible,test changes in a non-production environment first.
* ⁢ Documentation: ⁢ Always refer to the man usermod page for the most up-to-date⁣ and complete documentation. (man usermod in the terminal).
* User Login Status: Pay close attention to the warnings about users being logged⁤ in. Making changes while a user is logged in can lead to ⁤unpredictable behavior and data corruption.
* ⁢ ⁣ -aG for Groups: ⁣Remember to ⁢use -aG when adding a user to a group to append to their existing groups, rather than replacing them.

Let me know ⁢if you’d like more detail on any ⁣specific command or aspect of user management ⁢in Linux!

Share this:

  • Share on Facebook (Opens in new window) Facebook
  • Share on X (Opens in new window) X

Worth a look

  • Exoskeletons Evolve With Adaptive Algorithms and Soft Materials
  • TMOG monitors system performance on Windows, macOS and Linux

Related

Search:

News Directory 3

News Directory 3 catalogs US newspapers, news services, newsstands and digital news outlets across all 50 states. Browse local publishers by city, state, or topic, and follow current headlines linked back to their original sources.

Quick Links

  • Disclaimer
  • Terms and Conditions
  • About Us
  • Advertising Policy
  • Contact Us
  • Cookie Policy
  • Editorial Guidelines
  • Privacy Policy

Browse by State

  • Alabama
  • Alaska
  • Arizona
  • Arkansas
  • California
  • Colorado

© 2026 News Directory 3. All rights reserved.
For contact, advertising, copyright, issues email: office@newsdirectory3.com