0
0
Linux CLIscripting~5 mins

Why permissions protect system security in Linux CLI - Why It Works

Choose your learning style9 modes available
Introduction
Permissions control who can read, write, or run files and folders on a system. They protect the system by preventing unauthorized access or changes that could cause harm or data loss.
When you want to stop others from reading your private files on a shared computer
When you need to prevent accidental deletion or modification of important system files
When you want to allow only certain users to run specific programs
When you want to secure sensitive data from being accessed by unauthorized users
When you want to control access to shared resources like folders or devices
Commands
This command lists the file permissions, owner, and group of the /etc/passwd file to show who can access it and how.
Terminal
ls -l /etc/passwd
Expected OutputExpected
-rw-r--r-- 1 root root 2450 Apr 10 12:00 /etc/passwd
-l - Shows detailed information including permissions, owner, and group
This command changes the permissions of private.txt so only the owner can read and write it, blocking others from accessing it.
Terminal
chmod 600 /home/user/private.txt
Expected OutputExpected
No output (command runs silently)
This command verifies the new permissions on private.txt to confirm only the owner has read and write access.
Terminal
ls -l /home/user/private.txt
Expected OutputExpected
-rw------- 1 user user 1024 Apr 10 12:05 /home/user/private.txt
-l - Shows detailed file information including permissions
This command adds execute permission to script.sh so the owner, group, and others can run it as a program.
Terminal
chmod +x /home/user/script.sh
Expected OutputExpected
No output (command runs silently)
This command checks that the execute permission was added to script.sh.
Terminal
ls -l /home/user/script.sh
Expected OutputExpected
-rwxr-xr-x 1 user user 512 Apr 10 12:10 /home/user/script.sh
-l - Shows detailed file information including permissions
Key Concept

If you remember nothing else from this pattern, remember: permissions control who can access or change files, protecting your system from unauthorized use or damage.

Common Mistakes
Setting permissions too open like 777 on sensitive files
It allows anyone to read, write, and execute, risking data theft or damage
Use the least permissions needed, for example 600 for private files
Not verifying permissions after changing them
You might think permissions changed but they did not, leaving files unprotected
Always use ls -l to check permissions after chmod
Changing permissions on system files without understanding
It can break system functions or security
Only change permissions on files you own or understand
Summary
Use ls -l to see file permissions and ownership.
Use chmod to set who can read, write, or execute files.
Proper permissions protect files from unauthorized access or changes.