0
0
Linux CLIscripting~5 mins

Why user management secures systems in Linux CLI - Why It Works

Choose your learning style9 modes available
Introduction
User management controls who can access a computer system and what they can do. It helps keep the system safe by limiting access to only trusted people and preventing unauthorized actions.
When you want to give different people different levels of access on the same computer.
When you need to stop strangers from logging into your server.
When you want to track who made changes to files or settings.
When you want to remove access for someone who no longer works with you.
When you want to protect sensitive data by restricting access to certain users.
Commands
This command creates a new user named alice on the system. We run it first to add a user who will have controlled access.
Terminal
sudo adduser alice
Expected OutputExpected
Adding user `alice' ... Adding new group `alice' (1001) ... Adding new user `alice' (1001) with group `alice' ... Creating home directory `/home/alice' ... Copying files from `/etc/skel' ... Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully Changing the user information for alice Enter the new value, or press ENTER for the default Full Name []: Alice Example Room Number []: Work Phone []: Home Phone []: Other []: Is the information correct? [Y/n] Y
This command locks the user alice's password, preventing her from logging in. It is useful to temporarily disable a user without deleting the account.
Terminal
sudo passwd -l alice
Expected OutputExpected
Locking password for user alice.
This command adds alice to the sudo group, giving her permission to run commands as an administrator. This controls who can make important system changes.
Terminal
sudo usermod -aG sudo alice
Expected OutputExpected
No output (command runs silently)
-aG - Add user to supplementary groups without removing from others
This command removes the user alice from the system, revoking all her access. Use this when someone should no longer use the system.
Terminal
sudo deluser alice
Expected OutputExpected
Removing user `alice' ... Warning: group `alice' has no more members. Done.
Key Concept

If you remember nothing else from this pattern, remember: controlling who can log in and what they can do protects your system from unauthorized access and damage.

Common Mistakes
Creating users without setting strong passwords
Weak or no passwords let attackers easily guess and access accounts.
Always set strong, unique passwords when creating users.
Giving all users sudo rights by default
This lets anyone run dangerous commands that can harm the system.
Only add trusted users to sudo group and limit admin access.
Not removing users who no longer need access
Old accounts can be exploited by attackers to enter the system.
Regularly review and delete unused user accounts.
Summary
Add users to control who can access the system.
Lock or remove users to prevent unwanted access.
Use groups like sudo to manage permissions carefully.