Linux/Unix: User, Group & Security Management β Manage Accounts & Secure Your System
Introduction β Control Access and Enforce Security in Linux
Linux is built around the principle of multi-user environments and permission-based access. Whether you’re administering a shared server or setting up a personal workstation, knowing how to manage users, groups, authentication, and security tools is essential for system safety and structure.
In this guide, youβll learn:
- How to create, modify, and manage users and groups
- How to enforce authentication and privilege control using
sudo,passwd, andsu - How to view system identity and uptime
- How to use Linux tools for hardening and access restrictions
Topics Covered
| Category | Description |
|---|---|
| User & Group Management | Create and manage users, groups, and IDs |
| Authentication & Privileges | Secure access using passwords, sudo, and session management |
| System Identity Tools | View hostname, kernel, and uptime data |
| Basic Security Tools | Use firewalls and attribute tools for basic Linux system protection |
Linux/Unix: User & Group Management
Add and Manage Users
sudo useradd john
sudo passwd john
Adds a new user and sets their password.
Modify Existing Users
sudo usermod -aG sudo john # Add user to sudo group
sudo usermod -l newname oldname
Modify group access or rename users.
Group Management
groups john # List groups
sudo groupadd editors # Create group
sudo usermod -aG editors john
Identity Verification
id john # Show UID, GID, group membership
whoami # Current username
Linux/Unix: Authentication (passwd, su, sudo)
Set/Change Passwords
passwd john
Only root can reset othersβ passwords.
su β Switch User Temporarily
su - john
Switches to another userβs session.
sudo β Execute with Elevated Privileges
sudo apt update
Allows limited admin access without logging in as root.
Configure /etc/sudoers
Use:
sudo visudo
Add users to grant specific or full sudo rights safely.
Linux/Unix: System Info (uname, hostname, uptime)
View System Identity
uname -a # Kernel info
hostname # Hostname
uptime # System load and uptime
Quickly audit host details and runtime.
Linux/Unix: Basic Security Tools (chattr, semanage, ufw, firewalld)
chattr β File Attribute Control
sudo chattr +i file.txt # Make file immutable
sudo chattr -i file.txt
Prevents even root from modifying/deleting files unless reversed.
semanage β SELinux Policy Tool
semanage fcontext -l | grep ssh
Used with SELinux-enabled systems for context management.
ufw β Uncomplicated Firewall
sudo ufw enable
sudo ufw allow 22/tcp
Simple firewall setup (ideal for Ubuntu/Debian users).
firewalld β Dynamic Firewall Manager
sudo systemctl start firewalld
sudo firewall-cmd --add-service=http --permanent
sudo firewall-cmd --reload
Used on CentOS, Fedora, and RHEL for zone-based firewalling.
Summary β Recap & Next Steps
User, group, and security management form the backbone of Linux system control. Whether you’re configuring multi-user access or applying security hardening techniques, these tools help enforce accountability, permissions, and network safety.
Key Takeaways:
- Use
useradd,usermod, andgroupaddfor account management - Configure
sudocarefully to restrict elevated access - Use
ufworfirewalldto control network access - Make sensitive files immutable with
chattr
Real-World Applications:
- Manage user permissions in hosting or development servers
- Protect sensitive configuration files from tampering
- Implement secure sudo policies for team environments
- Block unwanted traffic via firewall rules
Frequently Asked Questions
Whatβs the difference between su and sudo?
su switches to another user shell; sudo runs a command with another user’s (usually root’s) privileges.
How do I give a user sudo access?
Add them to the sudo group or configure rules via visudo.
Can I delete a user safely without removing their files?
Yes:
sudo userdel username # Keeps home directory
sudo userdel -r username # Removes home too
How do I prevent accidental file deletion?
Use:
sudo chattr +i important.conf
Whatβs the best beginner-friendly firewall tool?
Use ufw on Ubuntu/Debian, and firewalld on RHEL-based systems.
Share Now :
