Close Menu
Financblog
    What's Hot

    Sen. Thom Tillis drops opposition, says he’ll back Kevin Warsh’s Fed confirmation

    April 26, 2026

    As mass layoffs threaten jobs, here are 4 smart moves to protect yourself

    April 26, 2026

    Grading Meta’s Severance Package Offer: Strong On The Surface

    April 26, 2026
    Facebook X (Twitter) Instagram
    Financblog
    Facebook X (Twitter) Instagram
    • Home
    • Personal Finance
    • Passive Income
    • Saving Tips
    • Banking
    • Loans
    Financblog
    Home»Saving Tips»How to Manage Users from the Command Line in Linux
    Saving Tips

    How to Manage Users from the Command Line in Linux

    administraciónBy administraciónMarch 18, 2026No Comments6 Mins Read
    Facebook Twitter LinkedIn Telegram Pinterest Tumblr Reddit WhatsApp Email
    Manage Users Linux
    Share
    Facebook Twitter LinkedIn Pinterest Email

    Managing users is one of the most important tasks for any Linux administrator. Whether you manage a single system or multiple servers, keeping user accounts organized helps maintain control over the system. Proper user management also plays a key role in system security. Administrators should only grant access to people who truly need it and only for the time they need it. Giving unnecessary privileges may expose sensitive data or critical system resources. Here, we will explore command-line tools that allow administrators to create, modify, and remove user accounts directly from the terminal.

    Key Files for Managing Linux Users

    Linux keeps user and group information in specific system files. These files store account details, passwords, and group settings, and administrators can use them to manage users and control access.

    File / Directory Description
    /etc/passwd Includes UID, GID, home directory, and default shell. Readable by all, editable only by root/sudo.
    /etc/group Shows group name, GID, and members. Used to manage group memberships and permissions.
    /etc/sudoers Specifies which users/groups can run commands as root. It must be edited carefully.
    /etc/shadow Includes password hashes, expiration dates, and account info. Root-only access.
    /etc/gshadow Contains group password info and expiration data. Root-only access.
    /etc/skel Files like “.bashrc” and “.profile” copied to new users’ home directories.
    /etc/login.defs Manages password aging, expiration, and other security rules.

    Viewing Existing Users

    One of the quickest ways to view existing users on a Linux system is to examine the “/etc/passwd” file. This file stores basic information about all user accounts. You can view it using the following command:

    sudo cat /etc/passwd

    Here, each line in the file represents one user account.

    View User Info

    Alternatively, you can also check user information using the following commands:

    id username
    groups username
    getent passwd username

    The id command shows the UID, GID, and all groups the user belongs to. The groups command only shows the groups that a user belongs to. It does not display the UID or GID. While the getent command retrieves user account details from the system databases, including “/etc/passwd”, LDAP, or other configured sources.

    View Existing Users Info

    Note: Modern Linux systems do not store password hashes in “/etc/passwd”. Instead, encrypted passwords are stored in the “/etc/shadow” file, which can only be accessed by the root user.

    Creating Users with the useradd Command

    useradd is a low-level binary available on most distros. This command is typically less used because it is not as user-friendly and intuitive as the adduser command. However, there are very few differences, and either can be used.

    To find out more about useradd, run the man command or add --help to get a quick overview.

    man useradd
    useradd --help
    Linux Useradd Help

    Run the following command to add a new user with a home directory:

    sudo useradd --create-home

    This command creates a user and generates a home directory for it. However, if you skip the --create-home option, the user account will be created without a personal directory. After this, you can verify the user creation using the grep command:

    grep /etc/passwd
    Create And Verify User

    Creating Users With the adduser Command

    The adduser command is a Perl script that will create a user similar to the useradd command. What makes it different is that it is an interactive command that prompts you to set the password, the home directory path, etc. On some distributions, such as Red Hat and CentOS, adduser is a symbolic link to useradd, and on other distributions like Arch Linux, adduser comes as a package that is not installed by default.

    By default, using this command creates a group for the user with the same name as the user’s login. Other default settings are typically stored in the “/etc/default/useradd” file. In this file, you can configure defaults for users created with useradd, such as the default shell, home directory location, and other account properties.

    Configure Defaults For User

    Run the following command to create a new user:

    sudo adduser testuser

    When creating a user, you will be prompted to set and confirm the password, provide optional user information, and confirm the account creation.

    Create User Using Adduser

    Setting or Changing User Passwords

    After creating a user account, you can set or update the user’s password using the passwd command.

    sudo passwd

    This command prompts you to enter and confirm a new password. If a regular user runs the passwd command without sudo, they can only change their own password.

    Set Update Password

    Password complexity requirements are enforced by PAM and are typically configured in “/etc/pam.d/common-password” on Ubuntu. For more information on updating password complexity rules, see the pam-auth-update man page.

    Linux Pam Auth Man

    Managing Linux Users Using the usermod Command

    You can use the usermod command to modify existing user accounts. It can change attributes such as user IDs, login names, home directories, or group memberships. For example, the following command updates the user’s UID:

    sudo usermod -u
    Change Uid Usermod

    Be careful when modifying critical attributes such as the user ID or login name. Changing these values may affect file ownership or permissions on the system.

    Similarly, you can change a user’s Home Directory with the usermod command as follows:

    sudo usermod -d

    In addition to this, you can lock or unlock a user account using the -L and -U options respectively:

    sudo usermod -L
    sudo usermod -U

    Finally, you can set the account’s expiration date using the --expiredate option with the usermod command:

    sudo usermod --expiredate

    These options allow you to control account access and manage user settings without deleting the account.

    Adding Users to the Groups

    Groups allow multiple users to share the same permissions. For example, users may need group access to manage files, run services, or perform administrative tasks.

    To add a user to a group, run the usermod command with -a and -G options:

    sudo usermod -a -G

    The -a flag means append, which ensures the user keeps their existing groups. Without this option, the command may overwrite the user’s group list.

    Add User To A Group

    Alternatively, you can use the gpasswd command to add/remove a user to/from a group.

    sudo gpasswd -a username groupname

    To remove a user from a group:

    sudo gpasswd -d username groupname

    Removing Users

    If a user account is no longer needed, you can remove it using the userdel command.

    sudo userdel username
    Delete User

    This command deletes the user account but keeps the user’s home directory. To remove both the account and its home directory, use the following command:

    sudo userdel -r username

    Note that userdel will not remove a user if there are active processes running under that account.

    Viewing User Login Activity

    Monitoring login activity helps administrators detect unauthorized access and troubleshoot authentication issues. On Ubuntu and Debian systems, login attempts are recorded in “/var/log/auth.log”. You can view recent entries using the tail command:

    sudo tail /var/log/auth.log
    View User Logs

    On Red Hat or CentOS systems, login records are stored in “/var/log/secure”. Systems that use systemd may also allow viewing authentication logs using the following command:

    sudo journalctl | grep ssh

    This way, managing user accounts correctly keeps your system organized and prevents unauthorized access. To take your terminal experience even further, check out this guide on Linux terminal tools for utilities that make working in the terminal faster and more enjoyable.

    Command line Linux manage users
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Telegram Email
    Previous ArticleUber’s stock powers higher as Nvidia robotaxi deal helps avert ‘doomsday’ scenario
    Next Article Iran strikes Tel Aviv with cluster warheads in retaliation for killing of security chief
    administración
    • Website

    Related Posts

    What is Emulation? Benefits, Downsides and More

    April 3, 2026

    Twitch vs. Facebook Gaming vs. YouTube Gaming: What’s the Best Live Game Streaming Platform?

    April 3, 2026

    WinX DVD Ripper: Quickly Rip and Digitize DVDs

    April 1, 2026
    Add A Comment
    Leave A Reply Cancel Reply

    Top Posts

    Sen. Thom Tillis drops opposition, says he’ll back Kevin Warsh’s Fed confirmation

    April 26, 2026

    As mass layoffs threaten jobs, here are 4 smart moves to protect yourself

    April 26, 2026

    Grading Meta’s Severance Package Offer: Strong On The Surface

    April 26, 2026

    Subscribe to Updates

    Get the latest sports news from SportsSite about soccer, football and tennis.

    About Us

    Welcome to FinancBlog, your trusted online resource for personal finance insights, money management tips, and financial education designed to help you make smarter financial decisions.
    At FinancBlog, our mission is simple: to make personal finance easy, understandable, and accessible for everyone. Whether you are looking to save more money, understand banking products, explore loans, or build passive income streams, we provide well-researched and easy-to-read information to guide you.

    Facebook X (Twitter) Instagram Pinterest YouTube
    a1
    Top Insights

    Sen. Thom Tillis drops opposition, says he’ll back Kevin Warsh’s Fed confirmation

    April 26, 2026

    As mass layoffs threaten jobs, here are 4 smart moves to protect yourself

    April 26, 2026

    Grading Meta’s Severance Package Offer: Strong On The Surface

    April 26, 2026
    Get Informed

    Subscribe to Updates

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

    © 2026 inancblog.com. All rights reserved. Designed by DD.

    • About Us
    • Contact Us
    • Terms & Conditions
    • Privacy Policy
    • Disclaimer

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

    Ad Blocker Enabled!
    Ad Blocker Enabled!
    Our website is made possible by displaying online advertisements to our visitors. Please support us by disabling your Ad Blocker.