π₯ 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 :
