File Permissions

Understanding File Permissions

Linux uses a permission system to control who can read, write, and execute files. Every file has three sets of permissions: for the owner, the group, and others.
bash
# View permissions with ls -l
ls -l
# -rw-r--r--  1 user group  1024 Jan 1 12:00 file.txt
# │├─┤├─┤├─┤
# │ │  │  └── others: read only
# │ │  └───── group: read only
# │ └──────── owner: read + write
# └────────── - = file, d = directory

# Change permissions with chmod
chmod 755 script.sh    # rwxr-xr-x
chmod +x script.sh     # Add execute permission
chmod u+w file.txt     # Add write for owner

Tip:Permission numbers: 4=read, 2=write, 1=execute. Add them up: 7=rwx, 6=rw-, 5=r-x, 4=r--.

Terminalbash
Welcome to the Linux Terminal Simulator!
Type commands below. Use 'help' to see available commands.
user@codewithmuh:~$
Try:

💬 Got questions? Ask me anything!