Linux user management

Linux User Management: Commands, Permissions, and Access Control

On Linux systems, proper user management is the foundation of security, stability, and audit compliance. One incorrectly configured user with root access can become a vulnerability for the entire infrastructure. Therefore, a system administrator must know not only basic commands, but also groups, permissions, restrictions, and activity logging.

๐Ÿ‘ฅ Basic user management commands

Here are the basic commands everyone should know:

TeamPurpose
adduser and useraddAdding a new user
passwdSetting or changing a password
usermodChanging user parameters
deluser and userdelDeleting a user
groups, idView groups
groupadd, groupdel, groupmodWorking with groups

๐Ÿ›ก๏ธ Access control: rights, groups and sudo

๐Ÿ“‚ File and directory permissions

Linux uses three categories of permissions: owner, group and others. Each of them can have permissions to:

  • r โ€” read
  • w โ€” write
  • x โ€” execute

Example:

-rwxr-xr-- 1 user group 1234 Apr 5 10:00 file.txt

| ๐Ÿ” Use chmod, chown, chgrp to manage permissions and owners.

๐Ÿ” Sudo and groups

  • Add user to sudo group:
usermod -aG sudo username
  • Check who has sudo access:
getent group sudo

๐Ÿ“ Managing home directories and shells

  • The home directory is created by default, but can be set manually:
useradd -m -d /home/new_path username
  • The default shell can be set like this:

๐Ÿง  Audit and security logic

To avoid audit failure and simplify control:

โœ… Disable unused accounts
โœ… Regularly check groups and sudo rights
โœ… Set up automatic removal of temporary users
โœ… Enable logging of logins and sudo usage

sudo log file:

/var/log/auth.log

๐Ÿ”„ Automation with Ansible (optional)

Simple playbook example for user creation:

- name: Add new user 
  hosts: all
  become: true
  tasks:
    - name: Create user
      user:
        name: devops
        shell: /bin/bash
        groups: sudo
        append: yes

Effective user management in Linux is a balance between convenience and security. Setting up shells, permissions, and group policies can prevent errors and increase transparency in your infrastructure.

๐Ÿ’ก Make your life easier, reduce risks, and always have a plan in case of an audit.


Leave a Reply

Your email address will not be published. Required fields are marked *

About Us

We are a team of IT enthusiasts, publishing practical articles for system administrators: automation, security, infrastructure and the best tools for daily work.

treefancy.com
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.