User permission and first commands
Permissions, Users and File System in Linux
This document summarizes key concepts about how permissions, users and directories work in Linux. It also explains useful commands and how to interpret binary and decimal representations.
Types of Users
In Linux there are 3 main types:
User (owner): who created the file
Group (group): set of users with shared permissions
Others (others): the rest of the world (literally)
How Permissions Work (rwx)
Each file or folder has permissions assigned in three blocks:
-rwxr-xr--
r → read
w → write
x → execute
This example means:
The owner can read, write and execute
The group can read and execute
Others can only read
Octal Notation
111
7
rwx
110
6
rw-
101
5
r-x
100
4
r--
011
3
-wx
010
2
-w-
001
1
--x
000
0
---
Examples:
chmod 777 file # Maximum permissions for everyone (rwx)
chmod 754 file # rwx for owner, r-x for group, r-- for others
chmod 666 file # rw- for everyone (nobody can execute it)
Useful Commands
Groups and Users
groups # View current user's groups
sudo adduser user1 # Create user
sudo deluser user1 # Delete user
sudo addgroup grupo # Create group
Permissions
chmod 755 file # Change permissions
chown user:group file # Change owner and group
File System in Linux
Linux has a tree-like hierarchical structure. Key examples:
/bin
Essential system commands
/etc
Configuration files
/home
User folders
/root
Superuser folder
/tmp
Temporary files
/var
Logs and variable files
What is a Binary File?
A binary is a file that contains code that can be executed directly by the system. It's compiled from source language (like C or C++).
How does binary work in Linux?
It's stored in locations like
/bin
,/usr/bin
It executes if it has execution permissions (x)
We use
chmod
to make it executable if it's not
Binary and Decimal System
Linux uses numerical systems to handle permissions.
The binary system is based on powers of 2.
Example:
Binary: 01100111
Equals to:
64 + 32 + 4 + 2 + 1 = 103
Each bit position (from right to left) is worth: 1, 2, 4, 8, 16, 32, 64, 128...
What relation does it have with IPs?
An IPv4 address is a sequence of 4 bytes → each byte goes from 0 to 255.
Example:
192.168.1.1 → 4 blocks of 8 bits each
Recommendations
Use
chmod
,chown
andls -l
to experiment with permissionsPlay around changing permissions on test files (not on system files!)
Look at the output of
ls -l /home
and analyze who has what permissions
Quick Reference Commands
ls -l # List files with detailed permissions
ls -la # Include hidden files
chmod +x script.sh # Add execute permission
chmod -w file.txt # Remove write permission
chown user:group file # Change ownership
stat filename # Show detailed file information
Last updated