Close Menu
GeekBlog

    Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    What's Hot

    This Clock Would Take 260 Billion Years to Lose One Second. The Universe Is 13.8 Billion Years Old.

    October 4, 2026

    One UI 9 Watch Beta Now Covers Three Galaxy Watch Generations: What You Get and How to Join

    October 4, 2026

    NASA Found Possible Signs of Life on Mars. To Check, It Went to a Beach in Scotland.

    October 4, 2026
    Facebook
    GeekBlog
    • Home
    • Mobile
    • Tech News
    • Blog
    • Gaming
    • Smartwatch
    • How-To Guides
    • AI & Software
    Facebook
    GeekBlog
    Home»Tech News»Need to modify user accounts in Linux? This is the command for you
    Tech News

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

    Michael ComaousBy Michael ComaousSeptember 16, 20255 Mins Read
    Share Facebook Twitter Pinterest LinkedIn Tumblr Email Copy Link
    Need to modify user accounts in Linux? This is the command for you
    Share
    Facebook Twitter LinkedIn Pinterest Email Copy Link

    Trevor Williams/DigitalVision via Getty

    Follow ZDNET: Add us as a preferred source on Google.


    The usermod command is short for user modification, and, as the name implies, allows you to modify various aspects of a user account. 

    For a Linux administrator, this command is crucial. For Linux users, the command most certainly comes in handy, especially given what it can do.

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

    1. Change user details

    When you create a Linux user with the adduser command, you can include certain details to go along with the new user (such as full name, office and home phone numbers, and other information, which can be used as a description. After you’ve created the user, the only way to change or add such information is via the usermod command. Say, for instance, you want to add a comment for a user. To do that, you would issue the command:

    sudo usermod -c “INFORMATION” USER

    Also: 5 surprisingly productive things you can do with the Linux terminal

    Where INFORMATION is what you want to add, and USER is the user account you want to change.

    This can be handy if you have two users with the same first name and you want to differentiate them in their user information. 

    2. Change a username

    You can also change a username. Before you do this, know that it does not change the user’s home directory name. So if I have the user sam and I want to change it to samantha, usermod is there to help me. Such a command would look like this:

    sudo usermod -l samantha sam

    The -l option is for the login name.

    3. Rename a home directory

    After you change a username, you might also want to rename the user’s home directory. Before you do this, you must ensure that the user is logged out; otherwise, it could wreak havoc on their account (or their data). You also need to make sure that the user’s data is added to the new home directory (otherwise, the user winds up with an empty home). To change a directory name (and add the data), you would use a command like this (sticking with our sam/samantha example):

    sudo usermod -d /home/samantha -m sam

    The -d option sets the new home directory path, and the -m option moves the data.

    Also: There’s a new coolest Linux distribution ready to wow you 

    4. Lock and unlock a user’s account

    There may be times when you need to lock a user out of their account (and later allow them back in). This could be used for temporary employees or grounded children. To lock a user account, the command would be:

    sudo usermod -L USER

    Where USER is the username to which the lock applies.

    To unlock the account, you would issue the command:

    sudo usermod -U USER

    Where USER is the user account.

    6. Change a user’s account expiry date

    Did you know you can expire a user account in Linux? Let’s say you have a temp employee whose contract ends on October 31, 2025. If you want to set the person’s user account to expire on that date (instead of having to remember it when the date arrives), you can use the expiry feature of usermod like so:

    sudo usermod -e 2025-10-31 USER

    Where USER is the user account name.

    7. Add a user to a group (or groups)

    I’ve had to use this feature so many times. For example, I use Docker a lot, and when I install it, I have to add users to the group (otherwise it won’t work for them without using sudo, which can lead to security issues). You might have also created a group that will be used by several accounts to access a specific folder. Let’s say you’ve created the editorial group and want to add sam to it. The command for that would be:

    sudo usermod -aG editorial sam

    Also: 7 Linux terminal basics every beginner should learn first – and why

    8. Modify a user’s home directory

    If you’ve renamed a user account, you’ll notice their home directory is still listed as the original username. If you would like to rename the user’s home directory (to avoid confusion), usermod has your back. Before you do this, however, it’s important that you make sure the user is logged out of their account (otherwise, it could cause serious problems).

    To change the name of a user’s home directory, the command would be:

    sudo usermod -d /home/NEWNAME OLDNAME

    Where NEWNAME is the new name for the directory and OLDNAME is the current name.

    9. Change a user’s shell

    Chances are pretty slim that you’ll ever need to do this, but you can change a user’s shell. Let’s say you want to change samantha’s shell from bash to zsh. To do that, you should first make sure the new shell is actually installed with the command:

    cat /etc/shells

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

    sudo usermod -s /bin/SHELL samantha

    Want to follow my work? Add ZDNET as a trusted source on Google.

    About this article: GeekBlog covers U.S. technology news, AI, phones, smartwatches and gaming. Every story is written and checked under our Editorial Policy. Spotted a mistake or have a story tip? Contact our editors.

    Linux
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Telegram Email Copy Link
    Previous Article11 Best Computer Monitors (2025): Budget, OLED, 4K
    Next Article Check Your Bank Accounts, You Might Spot a Deposit From a Facebook Lawsuit
    Michael Comaous

      Michael Comaous is a dedicated professional with a passion for technology, innovation, and creative problem-solving. Over the years, he has built experience across multiple industries, combining strategic thinking with hands-on expertise to deliver meaningful results. Michael is known for his curiosity, attention to detail, and ability to explain complex topics in a clear and approachable way. Whether he’s working on new projects, writing, or collaborating with others, he brings energy and a forward-thinking mindset to everything he does.

      Related Posts

      11 Mins Read

      This Clock Would Take 260 Billion Years to Lose One Second. The Universe Is 13.8 Billion Years Old.

      11 Mins Read

      NASA Found Possible Signs of Life on Mars. To Check, It Went to a Beach in Scotland.

      9 Mins Read

      Apple Put Video Into CarPlay and Millions of Drivers Cannot Find It. The Missing Piece Is the Car.

      11 Mins Read

      DoorDash’s AI Will Look Inside Your Fridge and Order Dinner. The Early Build Quoted the Wrong Prices.

      12 Mins Read

      NASA’s $30 Million Rescue Failed. It Turned the Falling Telescope Back On Anyway.

      12 Mins Read

      Nikon Is Investigating Its Contest Winner for Using AI. Its Own Profile Said He Does.

      Top Posts

      Best Free Online Music Apps in 2026

      July 7, 20263 Views

      Samsung Phones With the Best Camera Quality, Ranked

      July 4, 20262 Views

      When Is Anthropic Going Public? IPO Status 2026

      July 4, 20262 Views
      Stay In Touch
      • Facebook

      Subscribe to Updates

      Get the latest tech news from FooBar about tech, design and biz.

      Most Popular

      The Mesh Router Placement Strategy That Finally Gave Me Full Home Coverage

      September 9, 20263 Views

      Best Android Smartwatches in 2026: Which One Actually Fits Your Phone

      September 7, 20262 Views

      Gears of War: E-Day Reviews Are In: Best Gears in 15 Years, but the Campaign Drags

      October 1, 20261 Views
      Our Picks

      This Clock Would Take 260 Billion Years to Lose One Second. The Universe Is 13.8 Billion Years Old.

      October 4, 2026

      One UI 9 Watch Beta Now Covers Three Galaxy Watch Generations: What You Get and How to Join

      October 4, 2026

      NASA Found Possible Signs of Life on Mars. To Check, It Went to a Beach in Scotland.

      October 4, 2026

      Subscribe to Updates

      Get the latest creative news from FooBar about art, design and business.

      HEICJPG.online - Convert HEIC to JPG online
      Facebook
      • About Us
      • Contact us
      • Privacy Policy
      • Disclaimer
      • Terms and Conditions
      • Editorial Policy
      • Cookie Policy
      • Your Privacy Choices
      © 2026 GeekBlog

      Type above and press Enter to search. Press Esc to cancel.