Could we help you? Please click the banners. We are young and desperately need the money
You're using Linux as your daily driver. Everything is going fine until you try to run a script you just downloaded:
bash: ./install.sh: Permission denied
Or you plug in a USB drive and can't delete files on it. Or you try to edit a config file and get told you need to be root. Or you set up a shared folder for your family and suddenly nobody can access each other's files.
The instinct is to throw sudo at everything or Google "chmod 777" and hope for the best. It works—until it doesn't, or until you've created a security mess.
Linux permissions and groups aren't complicated once you understand the logic. In this guide, I'll explain how permissions actually work, what groups are for, and how to solve common desktop problems without blindly copy-pasting commands.
Every file and folder on your Linux system has three properties:
Permissions control three actions:
These permissions are set separately for three categories: the owner, the group, and others (everyone else on the system).
Open your terminal and run:
ls -l ~/Documents
You'll see something like:
-rw-rw-r-- 1 maria maria 4521 Jan 20 14:30 notes.txt
drwxrwxr-x 2 maria maria 4096 Jan 18 09:15 Projects
-rw------- 1 maria maria 256 Jan 15 11:00 passwords.txt
-rwxrwxr-x 1 maria maria 892 Jan 22 16:45 backup.sh
Let's break down -rw-rw-r--:
- rw- rw- r--
│ │ │ │
│ │ │ └── Others: read only
│ │ └── Group: read + write
│ └── Owner: read + write
└── File type (- = file, d = directory)
The two names after the permissions show the owner and group. In maria maria, the file is owned by user maria and belongs to group maria (Linux creates a personal group for each user by default).
Here's what each file in our example allows:
You've probably seen commands like chmod 755 somefile. Those numbers are just shorthand for permissions.
Each permission has a value:
Add them together for each category:
rwx = 4 + 2 + 1 = 7 (full access)
rw- = 4 + 2 + 0 = 6 (read and write)
r-x = 4 + 0 + 1 = 5 (read and execute)
r-- = 4 + 0 + 0 = 4 (read only)
--- = 0 + 0 + 0 = 0 (no access)
A three-digit number represents owner, group, and others:
chmod 755 script.sh
│││
││└── Others: 5 (r-x) - read and execute
│└── Group: 5 (r-x) - read and execute
└── Owner: 7 (rwx) - full access
Common permission numbers you'll encounter:
The chmod command changes permissions. You can use numbers or letters.
# Make a script executable
chmod 755 backup.sh
# Make a file private
chmod 600 passwords.txt
# Standard permissions for a regular file
chmod 644 document.txt
Sometimes letters are clearer for quick changes:
# Add execute permission for owner
chmod u+x script.sh
# Remove write permission for others
chmod o-w shared-file.txt
# Add read permission for group
chmod g+r project-notes.txt
# Add execute for everyone
chmod +x installer.sh
The letters mean:
And the operators:
Sometimes the problem isn't permissions—it's ownership. If a file is owned by root or another user, you can't modify it even with generous permissions.
Check who owns a file:
ls -l somefile.txt
# -rw-r--r-- 1 root root 1024 Jan 20 10:00 somefile.txt
This file is owned by root. Even though it's readable, you can't modify it as a regular user.
Change ownership with chown:
# Change owner to yourself
sudo chown maria somefile.txt
# Change owner and group
sudo chown maria:maria somefile.txt
# Change ownership of a folder and everything inside
sudo chown -R maria:maria ~/Projects
You need sudo for chown because only root can give files to other users.
Groups let multiple users share access to files without opening them to everyone on the system.
Every user belongs to at least one group (their personal group, usually named after their username). But users can belong to multiple groups.
See your groups:
groups
Output might look like:
maria adm cdrom sudo plugdev lpadmin sambashare
This shows maria belongs to several groups. Some important ones:
See all groups on the system:
cat /etc/group
Create a new group:
sudo groupadd family
Add a user to a group:
# Add maria to the family group
sudo usermod -aG family maria
The -aG flags are important:
After adding yourself to a group, you need to log out and log back in for it to take effect. Or use:
newgrp family
# Change group only
chown :family shared-folder
# Or use chgrp
chgrp family shared-folder
Let's solve common desktop permission problems.
You download a script from GitHub and try to run it:
./install.sh
# bash: ./install.sh: Permission denied
Check the permissions:
ls -l install.sh
# -rw-rw-r-- 1 maria maria 2048 Jan 20 10:00 install.sh
No execute permission. Fix it:
chmod +x install.sh
./install.sh
You try to edit a system config:
nano /etc/hosts
# Error: /etc/hosts is unwritable
Check ownership:
ls -l /etc/hosts
# -rw-r--r-- 1 root root 224 Jan 15 08:00 /etc/hosts
It's owned by root. You have two options:
# Option 1: Edit with sudo
sudo nano /etc/hosts
# Option 2: For files you edit often, change ownership (careful with system files)
sudo chown maria /etc/someconfig
For system files like /etc/hosts, always use sudo rather than changing ownership.
You plug in a USB drive but can't write to it. This usually happens with NTFS or FAT32 drives.
First, check how it's mounted:
mount | grep media
For NTFS drives, install ntfs-3g if you haven't:
sudo apt install ntfs-3g
If the drive was improperly ejected from Windows, it might be locked. Fix it:
sudo ntfsfix /dev/sdb1
For FAT32 drives, remount with write permissions:
sudo umount /dev/sdb1
sudo mount -o rw,uid=$(id -u),gid=$(id -g) /dev/sdb1 /mnt/usb
You want a folder that both you and your partner can access on a shared computer.
Create a shared group and folder:
# Create a group for sharing
sudo groupadd shared
# Add both users to the group
sudo usermod -aG shared maria
sudo usermod -aG shared alex
# Create a shared folder
sudo mkdir /home/shared
# Set ownership to root:shared
sudo chown root:shared /home/shared
# Set permissions: owner and group can read/write, others can't access
sudo chmod 770 /home/shared
# Make new files inherit the group
sudo chmod g+s /home/shared
The g+s flag is called setgid. It makes new files in that folder inherit the group, so everything created there automatically belongs to the shared group.
Both users need to log out and back in for the group changes to take effect.
You download an AppImage or binary and it won't run:
./SomeApp.AppImage
# bash: ./SomeApp.AppImage: Permission denied
Same fix as scripts—add execute permission:
chmod +x SomeApp.AppImage
./SomeApp.AppImage
After copying files from a Windows partition or NTFS drive, everything might have execute permissions (shown in green in ls):
ls -l
# -rwxrwxrwx 1 maria maria 1024 photo.jpg
# -rwxrwxrwx 1 maria maria 2048 document.pdf
Fix permissions for normal files:
# Remove execute from all files in current directory
chmod -x *
# If you have subdirectories, fix files only (not folders)
find . -type f -exec chmod 644 {} \;
# Fix folder permissions separately
find . -type d -exec chmod 755 {} \;
sudo lets you run a command as root (the superuser). Use it only when necessary:
A common mistake is using sudo to create or edit files in your home directory. This creates files owned by root, which causes more permission problems:
# Bad: creates a root-owned file in your home
sudo nano ~/notes.txt
# Good: just edit normally
nano ~/notes.txt
If you've already created root-owned files in your home folder, fix them:
sudo chown -R $(whoami):$(whoami) ~
This gives everyone full access. It's almost never the solution:
Bad:
chmod 777 myfile
Good:
# Figure out what you actually need
chmod 755 myscript.sh # For scripts
chmod 644 myfile.txt # For regular files
Be careful with -R (recursive):
Bad:
# Makes everything executable, including documents
chmod -R 755 ~/Documents
Good:
# Set different permissions for files and folders
find ~/Documents -type f -exec chmod 644 {} \;
find ~/Documents -type d -exec chmod 755 {} \;
Group changes don't apply to your current session. Log out and back in, or use newgrp groupname.
Bad:
sudo nautilus
sudo gedit /etc/hosts
Good:
# Use pkexec or admin:// for GUI apps that need root
pkexec gedit /etc/hosts
# Or in file managers, use admin://
# Type in address bar: admin:///etc/hosts
# List with permissions
ls -l
# List including hidden files
ls -la
# See your username
whoami
# See your groups
groups
# See groups for another user
groups alex
# See file info in detail
stat filename
# Using numbers
chmod 644 file.txt
chmod 755 script.sh
# Using letters
chmod +x script.sh # Add execute for everyone
chmod u+w file.txt # Add write for owner
chmod go-w file.txt # Remove write for group and others
# Recursive (folders and contents)
chmod -R 755 folder/
# Change owner
sudo chown maria file.txt
# Change owner and group
sudo chown maria:developers file.txt
# Change group only
chgrp developers file.txt
# or
chown :developers file.txt
# Recursive
sudo chown -R maria:maria folder/
# Create a group
sudo groupadd groupname
# Delete a group
sudo groupdel groupname
# Add user to group
sudo usermod -aG groupname username
# Remove user from group
sudo gpasswd -d username groupname
# See group members
getent group groupname
Linux permissions protect your system and your privacy. Instead of fighting them with sudo and chmod 777, understanding how they work lets you fix problems properly.
Key takeaways:
Next time you hit "Permission denied," check the permissions with ls -l, figure out what's actually wrong, and fix it properly. Your system will be more secure and you'll actually understand what's happening.