{"id":424,"date":"2026-07-24T04:00:54","date_gmt":"2026-07-24T04:00:54","guid":{"rendered":"https:\/\/networkyy.com\/how-to-manage-users-and-groups-in-linux\/"},"modified":"2026-08-23T16:29:36","modified_gmt":"2026-08-23T16:29:36","slug":"how-to-manage-users-and-groups-in-linux","status":"publish","type":"post","link":"https:\/\/networkyy.com\/fr\/how-to-manage-users-and-groups-in-linux\/","title":{"rendered":"How to Manage Users and Groups in Linux"},"content":{"rendered":"<figure><img decoding=\"async\" src=\"https:\/\/images.pexels.com\/photos\/8088689\/pexels-photo-8088689.jpeg?auto=compress&#038;cs=tinysrgb&#038;dpr=2&#038;h=650&#038;w=940\" alt=\"How to Manage Users and Groups in Linux\" style=\"width:100%;height:auto;border-radius:8px;margin-bottom:24px;\" \/><figcaption>Photo by cottonbro studio on Pexels<\/figcaption><\/figure>\n<h1>How to Manage Users and Groups in Linux<\/h1>\n<p>Managing users and groups is a fundamental skill for any Linux system administrator. Whether you&#8217;re running a personal server, managing enterprise infrastructure, or developing on a local machine, understanding how to properly control user access and permissions is crucial for maintaining system security and organization.<\/p>\n<p>In this comprehensive guide, you&#8217;ll learn the essential commands and best practices for managing users and groups in Linux, from basic account creation to advanced permission management.<\/p>\n<h2>Table of Contents<\/h2>\n<ul>\n<li><a href=\"#understanding-users-groups\">Understanding Users and Groups in Linux<\/a><\/li>\n<li><a href=\"#creating-users\">Creating and Managing User Accounts<\/a><\/li>\n<li><a href=\"#managing-groups\">Managing Groups<\/a><\/li>\n<li><a href=\"#user-modification\">Modifying User Accounts<\/a><\/li>\n<li><a href=\"#permissions\">Understanding File Permissions and Ownership<\/a><\/li>\n<li><a href=\"#best-practices\">Security Best Practices<\/a><\/li>\n<li><a href=\"#troubleshooting\">Common Issues and Troubleshooting<\/a><\/li>\n<\/ul>\n<h2 id=\"understanding-users-groups\">Understanding Users and Groups in Linux<\/h2>\n<p>Linux is a multi-user operating system where each user has a unique identity and specific permissions. Users are organized into groups, which simplify permission management by allowing administrators to assign rights to multiple users simultaneously.<\/p>\n<h3>Key Concepts<\/h3>\n<p>Every user account in Linux has several important attributes:<\/p>\n<ul>\n<li><strong>Username:<\/strong> The unique identifier for the user<\/li>\n<li><strong>User ID (UID):<\/strong> A numeric identifier assigned to each user<\/li>\n<li><strong>Group ID (GID):<\/strong> The primary group associated with the user<\/li>\n<li><strong>Home Directory:<\/strong> The user&#8217;s personal workspace, typically \/home\/username<\/li>\n<li><strong>Shell:<\/strong> The command-line interface assigned to the user<\/li>\n<\/ul>\n<p>User information is stored in the <code>\/etc\/passwd<\/code> file, while password hashes are kept in <code>\/etc\/shadow<\/code>. Group information resides in <code>\/etc\/group<\/code>.<\/p>\n<h2 id=\"creating-users\">Creating and Managing User Accounts<\/h2>\n<h3>Adding New Users<\/h3>\n<p>The <code>useradd<\/code> command is the primary tool for creating new user accounts. Here&#8217;s the basic syntax:<\/p>\n<pre><code>sudo useradd -m -s \/bin\/bash john<\/code><\/pre>\n<p>This command creates a new user named &#8220;john&#8221; with a home directory (-m) and sets bash as the default shell (-s). However, this user cannot log in yet because no password has been set.<\/p>\n<p>To set a password for the new user:<\/p>\n<pre><code>sudo passwd john<\/code><\/pre>\n<p>For a more comprehensive user creation with additional options:<\/p>\n<pre><code>sudo useradd -m -d \/home\/john -s \/bin\/bash -c \"John Smith\" -G sudo,developers john<\/code><\/pre>\n<p>This command creates a user with a custom home directory (-d), a comment field (-c) for the full name, and adds the user to supplementary groups (-G).<\/p>\n<h3>The adduser Command<\/h3>\n<p>On Debian-based distributions like Ubuntu, the <code>adduser<\/code> command provides a more user-friendly, interactive approach:<\/p>\n<pre><code>sudo adduser john<\/code><\/pre>\n<p>This interactive script prompts you for all necessary information, including password and user details. If you&#8217;re learning Linux system administration, platforms like <a href=\"https:\/\/datacamp.pxf.io\/YR9dQK\" target=\"_blank\" rel=\"nofollow sponsored noopener\">DataCamp<\/a> offer hands-on courses that help you master these essential commands through practical exercises.<\/p>\n<h3>Deleting Users<\/h3>\n<p>To remove a user account:<\/p>\n<pre><code>sudo userdel john<\/code><\/pre>\n<p>To delete the user and their home directory:<\/p>\n<pre><code>sudo userdel -r john<\/code><\/pre>\n<h2 id=\"managing-groups\">Managing Groups<\/h2>\n<h3>Creating Groups<\/h3>\n<p>Groups allow you to manage permissions for multiple users efficiently. To create a new group:<\/p>\n<pre><code>sudo groupadd developers<\/code><\/pre>\n<p>To create a group with a specific GID:<\/p>\n<pre><code>sudo groupadd -g 1500 developers<\/code><\/pre>\n<h3>Adding Users to Groups<\/h3>\n<p>To add an existing user to a group:<\/p>\n<pre><code>sudo usermod -aG developers john<\/code><\/pre>\n<p>The -a flag appends the group to the user&#8217;s existing groups, while -G specifies the group name. Without -a, you would replace all supplementary groups.<\/p>\n<p>To add multiple users to a group:<\/p>\n<pre><code>sudo gpasswd -M john,jane,bob developers<\/code><\/pre>\n<h3>Viewing Group Membership<\/h3>\n<p>To see which groups a user belongs to:<\/p>\n<pre><code>groups john<\/code><\/pre>\n<p>Or use the <code>id<\/code> command for more detailed information:<\/p>\n<pre><code>id john<\/code><\/pre>\n<h3>Deleting Groups<\/h3>\n<p>To remove a group:<\/p>\n<pre><code>sudo groupdel developers<\/code><\/pre>\n<h2 id=\"user-modification\">Modifying User Accounts<\/h2>\n<p>The <code>usermod<\/code> command is your primary tool for modifying existing user accounts.<\/p>\n<h3>Common Modifications<\/h3>\n<p>Change a user&#8217;s home directory:<\/p>\n<pre><code>sudo usermod -d \/new\/home\/path -m john<\/code><\/pre>\n<p>Change the default shell:<\/p>\n<pre><code>sudo usermod -s \/bin\/zsh john<\/code><\/pre>\n<p>Lock a user account (disable login):<\/p>\n<pre><code>sudo usermod -L john<\/code><\/pre>\n<p>Unlock a user account:<\/p>\n<pre><code>sudo usermod -U john<\/code><\/pre>\n<p>Change username:<\/p>\n<pre><code>sudo usermod -l newname oldname<\/code><\/pre>\n<h2 id=\"permissions\">Understanding File Permissions and Ownership<\/h2>\n<p>User and group management is closely tied to file permissions. Every file and directory in Linux has an owner (user) and a group.<\/p>\n<h3>Viewing Permissions<\/h3>\n<p>Use the <code>ls -l<\/code> command to view file permissions and ownership:<\/p>\n<pre><code>ls -l \/home\/john\/document.txt<\/code><\/pre>\n<h3>Changing Ownership<\/h3>\n<p>To change the owner of a file:<\/p>\n<pre><code>sudo chown john document.txt<\/code><\/pre>\n<p>To change both owner and group:<\/p>\n<pre><code>sudo chown john:developers document.txt<\/code><\/pre>\n<p>To recursively change ownership of a directory:<\/p>\n<pre><code>sudo chown -R john:developers \/var\/www\/project<\/code><\/pre>\n<h3>Changing Group Ownership<\/h3>\n<p>To change only the group:<\/p>\n<pre><code>sudo chgrp developers document.txt<\/code><\/pre>\n<h2 id=\"best-practices\">Security Best Practices<\/h2>\n<p>Proper user and group management is essential for system security. Here are critical best practices to follow:<\/p>\n<h3>Principle of Least Privilege<\/h3>\n<p>Grant users only the minimum permissions necessary to perform their tasks. Avoid adding users to the sudo group unless they genuinely need administrative access.<\/p>\n<h3>Use Strong Password Policies<\/h3>\n<p>Implement password aging and complexity requirements by editing <code>\/etc\/login.defs<\/code> and using tools like <code>chage<\/code>:<\/p>\n<pre><code>sudo chage -M 90 -m 7 -W 14 john<\/code><\/pre>\n<p>This sets a maximum password age of 90 days, minimum of 7 days between changes, and a 14-day warning before expiration.<\/p>\n<h3>Regular Audits<\/h3>\n<p>Periodically review user accounts and group memberships. Remove or disable accounts for users who no longer need access.<\/p>\n<p>List all users:<\/p>\n<pre><code>cat \/etc\/passwd | cut -d: -f1<\/code><\/pre>\n<p>Find users with sudo privileges:<\/p>\n<pre><code>getent group sudo<\/code><\/pre>\n<h3>Secure Testing Environments<\/h3>\n<p>When practicing user management or deploying applications, consider using cloud instances from providers like <a href=\"https:\/\/kamatera.sjv.io\/engON1\" target=\"_blank\" rel=\"nofollow sponsored noopener\">Kamatera<\/a>, which offer flexible Linux environments where you can safely experiment without risking production systems.<\/p>\n<h2 id=\"troubleshooting\">Common Issues and Troubleshooting<\/h2>\n<h3>User Cannot Login<\/h3>\n<p>If a user cannot log in, check these common issues:<\/p>\n<ul>\n<li>Verify the account isn&#8217;t locked: <code>sudo passwd -S username<\/code><\/li>\n<li>Check if the password is set properly<\/li>\n<li>Verify the shell is valid: <code>cat \/etc\/passwd | grep username<\/code><\/li>\n<li>Ensure the home directory exists and has correct permissions<\/li>\n<\/ul>\n<h3>Permission Denied Errors<\/h3>\n<p>When users encounter permission errors:<\/p>\n<ul>\n<li>Verify file ownership with <code>ls -l<\/code><\/li>\n<li>Check group membership with <code>groups username<\/code><\/li>\n<li>Ensure the user has been added to necessary groups<\/li>\n<li>Remember that group changes require logout\/login to take effect<\/li>\n<\/ul>\n<h3>Viewing Recent User Activity<\/h3>\n<p>To monitor user logins:<\/p>\n<pre><code>last -a<\/code><\/pre>\n<p>To see currently logged-in users:<\/p>\n<pre><code>who<\/code><\/pre>\n<h2>Conclusion<\/h2>\n<p>Mastering user and group management in Linux is essential for maintaining secure, well-organized systems. From creating user accounts with <code>useradd<\/code> and <code>adduser<\/code> to managing groups and permissions, these fundamental skills form the foundation of Linux system administration.<\/p>\n<p>Remember to follow security best practices, regularly audit your user accounts, and always apply the principle of least privilege. As you gain experience, these commands will become second nature, allowing you to efficiently manage users across any Linux distribution.<\/p>\n<p>Whether you&#8217;re managing a single server or an entire infrastructure, the knowledge you&#8217;ve gained here will serve you well in your Linux administration journey.<\/p>\n<div style=\"background:#1a1a2e;color:#fff;padding:24px;border-radius:10px;margin-top:32px;border-left:4px solid #00ff88;\">\n<h3 style=\"color:#00ff88;margin-top:0;\">Follow Networkyy<\/h3>\n<p>Join 125,000+ IT professionals:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.instagram.com\/networkyy\" target=\"_blank\" style=\"color:#00ff88;\" rel=\"noopener\">Instagram @networkyy<\/a><\/li>\n<li><a href=\"https:\/\/www.facebook.com\/ITnetworkyy\/\" target=\"_blank\" style=\"color:#00ff88;\" rel=\"noopener\">Facebook Networkyy<\/a><\/li>\n<li><a href=\"https:\/\/www.threads.com\/@networkyy\" target=\"_blank\" style=\"color:#00ff88;\" rel=\"noopener\">Threads @networkyy<\/a><\/li>\n<li><a href=\"https:\/\/medium.com\/@mattouchi6\" target=\"_blank\" style=\"color:#00ff88;\" rel=\"noopener\">Medium<\/a><\/li>\n<\/ul>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>Learn essential Linux user and group management commands. Master useradd, usermod, groupadd, and permissions for secure system administration.<\/p>","protected":false},"author":2,"featured_media":423,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":"","_yoast_wpseo_title":"","_yoast_wpseo_metadesc":"","_yoast_wpseo_focuskw":"","rank_math_title":"","rank_math_description":"","rank_math_focus_keyword":""},"categories":[9],"tags":[],"class_list":["post-424","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux-sysadmin"],"contentshake_article_id":"","brizy_media":[],"_links":{"self":[{"href":"https:\/\/networkyy.com\/fr\/wp-json\/wp\/v2\/posts\/424","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/networkyy.com\/fr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/networkyy.com\/fr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/networkyy.com\/fr\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/networkyy.com\/fr\/wp-json\/wp\/v2\/comments?post=424"}],"version-history":[{"count":1,"href":"https:\/\/networkyy.com\/fr\/wp-json\/wp\/v2\/posts\/424\/revisions"}],"predecessor-version":[{"id":604,"href":"https:\/\/networkyy.com\/fr\/wp-json\/wp\/v2\/posts\/424\/revisions\/604"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/networkyy.com\/fr\/wp-json\/wp\/v2\/media\/423"}],"wp:attachment":[{"href":"https:\/\/networkyy.com\/fr\/wp-json\/wp\/v2\/media?parent=424"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/networkyy.com\/fr\/wp-json\/wp\/v2\/categories?post=424"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/networkyy.com\/fr\/wp-json\/wp\/v2\/tags?post=424"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}