
👤 Types of Users in Linux
Linux systems generally categorize users into three main types:1. Root User
* Username:root
* UID: 0
* Permissions: Full control over the system
* Caution: Misuse can lead to system instability or security breaches2. System Users
* Created automatically during OS or package installations * Typically used by background services likemysql, nginx, or sshd
* No login access (shell is often /sbin/nologin)3. Regular Users
* Created manually by admins or during OS setup * UID typically starts from 1000+ * Used for standard daily tasks👥 Groups in Linux
Groups are a way to organize users and assign permissions collectively.* Primary Group: Set when the user is created * Secondary Groups: Additional groups that provide extended accessUseful Commands:
BASH
# Add a new group
sudo groupadd developers
# Add a user to a group
sudo usermod -aG developers alice
# View group membership
groups alice🔐 Role-Based Access Control (RBAC)
RBAC assigns permissions to users based on their roles, which are often mapped through group membership.RoleExample GroupAccess RightsDeveloperdevsAccess to source code, staging environmentsDatabase AdmindbadminsManage and configure databasesSystem AuditorauditorsRead-only access to logs and metricsDeployment AgentdeployDeploy code and restart services🚫 Restricting Unauthorized Users
Linux allows restrictions on users through file permissions, shell access, and sudo configurations.1. File and Directory Permissions
BASH
# Restrict directory access to owner only
chmod 700 /srv/private-data2. Sudoers File Configuration
Usevisudo to give limited sudo rights:
BASH
# Allow 'deploy' group to restart services without a password
%deploy ALL=(ALL) NOPASSWD: /bin/systemctl restart myapp.service3. Restrict Shell Access
BASH
# Disable login for service users
usermod -s /sbin/nologin ftpuser4. Use Chroot or Containers
Isolate users withchroot environments or Docker containers for secure execution.
