Linux File Permissions Explained: chmod, chown and Practical Examples
To change file permissions in Linux, use the chmod command followed by either symbolic notation (like chmod u+x file) or numeric octal notation (like chmod 755 file). Permissions control who can read, write, or execute a file. Every Linux file has three permission sets: user, group, and other.
- Open a terminal on your Linux system.
- Run
ls -l filenameto check the current permissions of a file. - Run
chmod [mode] filenameto change file permissions in Linux using numeric or symbolic mode. - Run
chown [owner]:[group] filenameto change file ownership. - Add the
-Rflag to apply changes recursively to a directory.
- Key Takeaway 1: Every Linux file has three permission classes: user (owner), group, and other.
- Key Takeaway 2: chmod changes permissions; chown changes ownership. They do different jobs.
- Key Takeaway 3: Numeric (octal) mode is faster once you know it. Symbolic mode is easier to read.
- Key Takeaway 4: chmod 777 grants full access to everyone on the system. It is almost always the wrong choice.
- Key Takeaway 5: Permissions questions appear regularly in cybersecurity and Linux sysadmin interviews.
How to Read Linux File Permissions: Decoding ls -l
Before you change file permissions in Linux, you need to know how to check them. Run ls -l in any directory and you will see output like this:
-rwxr-xr– 1 rahul developers 4096 Jun 10 09:15 deploy.sh
That first column, -rwxr-xr–, is the permission string. Let us decode it character by character so it sticks.
Breaking Down the Permission String
The first character is the file type. A hyphen (–) means a regular file; a d means a directory. The next nine characters split into three groups of three, one group each for user, group, and other.
| Position | Characters | Who | Meaning |
|---|---|---|---|
| 2-4 | rwx | User (owner) | Read, Write, Execute |
| 5-7 | r-x | Group | Read, No Write, Execute |
| 8-10 | r– | Other | Read only |
A letter means the permission is granted. A hyphen means it is denied. The rwx model is the backbone of Linux access control, and the Linux Foundation’s own training materials confirm it has not changed since the earliest Unix systems.
Octal Values You Need to Memorise
Each permission has a numeric value: r = 4, w = 2, x = 1. You add them together per group. So rwx = 7, r-x = 5, r– = 4. The permission string above becomes 754 in octal notation.
According to the Stack Overflow Developer Survey 2023, Linux is the most used operating system among professional developers at 53.9%. Knowing octal chmod is a baseline skill, not an advanced one. In India, where Linux powers the majority of enterprise server infrastructure at firms like TCS, Infosys, and Wipro, this knowledge is tested from the first technical interview round.
Quick Reference: Common Permission Patterns
| Octal | Symbolic | Typical Use Case |
|---|---|---|
| 600 | rw——- | SSH private keys, sensitive config files |
| 644 | rw-r–r– | Web files, HTML, CSS, general documents |
| 700 | rwx—— | Private scripts, personal home directories |
| 755 | rwxr-xr-x | Public scripts, shared directories, binaries |
| 777 | rwxrwxrwx | Almost never appropriate in production |
How to Change File Permissions in Linux with chmod
chmod stands for “change mode.” You can use it in two ways: symbolic mode and numeric (octal) mode. Both work. The one you pick depends on context.
Symbolic Mode
Symbolic mode uses letters to specify who and what. The syntax is chmod [who][operator][permission] filename. Who can be u (user), g (group), o (other), or a (all). Operators are + (add), – (remove), or = (set exactly).
- chmod u+x script.sh adds execute for the owner only
- chmod g-w report.txt removes write from the group
- chmod o=r config.yml sets others to read-only, nothing else
- chmod a+r readme.md gives everyone read access
Symbolic mode is ideal when you want to add or remove one specific permission without touching the rest. It is also easier to audit when you are reading a shell script written by someone else.
Numeric (Octal) Mode
Numeric mode is faster for experienced users. You write a three-digit number and chmod applies all permissions at once.
- chmod 755 script.sh gives the owner rwx; group and others get r-x
- chmod 644 index.html gives the owner rw-; group and others get r– (standard for web files)
- chmod 600 id_rsa gives the owner rw-; nobody else gets anything (correct for SSH private keys)
- chmod 700 /home/rahul/private/ gives the owner full access only
For directories, execute permission means the ability to enter the directory. If you want to know how to give permission to a folder in Linux, use chmod 755 foldername for shared folders or chmod 700 for private ones. Add the -R flag to apply recursively: chmod -R 755 /var/www/html.
How to Change File Permissions in Linux Safely: Avoiding chmod 777
chmod 777 grants read, write, and execute permission to absolutely everyone on the system, including other users, web server processes, and any attacker who gains a foothold. It is the most common beginner mistake in Linux administration.
The OWASP Top 10 2021 lists “Security Misconfiguration” as the fifth most critical web application risk, and overly permissive file permissions are a textbook example. India’s CERT-In has issued multiple advisories (including CERT-In Advisory CIAD-2023 series) about misconfigured Linux servers being exploited through access control failures on internet-facing systems.
If a web application running on your server can write to its own files because of 777, an attacker who finds a file upload vulnerability can drop a web shell and compromise the entire server. Use 755 for directories and 644 for files as your default starting point. Restrict further from there, never loosen.
If you are just getting started with Linux commands, the Kali Linux for beginners guide on 3University covers the essential command-line foundations you will need before going deeper into permissions.
How to Change the Owner of a File in Linux with chown
chmod changes what actions are allowed. chown changes who owns the file. These are two separate controls and you need both to manage a Linux system properly.
The basic syntax is chown [owner]:[group] filename. Here are real examples:
- chown rahul deploy.sh changes the file owner to rahul
- chown rahul:developers deploy.sh changes owner to rahul and group to developers
- chown :developers deploy.sh changes only the group, leaves owner untouched
- chown -R www-data:www-data /var/www/html recursively sets owner and group for an entire web root (common on Ubuntu/Debian servers)
You need root or sudo to change ownership to another user. A regular user can only change the group of a file they own, and only to a group they belong to.
chown vs chgrp
There is also chgrp, which only changes the group. Most sysadmins use chown with the colon syntax instead. chgrp exists for legacy reasons and you will see it in older scripts, so it is worth recognising even if you do not use it day to day.
umask: The Default Permissions Every Linux File Starts With
When a new file is created, its default permissions come from umask. The umask is a mask that subtracts permissions from the default. A umask of 022 means new files get 644 (rw-r–r–) and new directories get 755. Run umask with no arguments to see your current setting. Understanding umask is the difference between a junior admin and someone who actually understands how Linux access control works end to end.
According to Red Hat’s 2023 Linux Administrator Skills Report, file permissions and ownership management rank among the top five skills tested in entry-level Linux job assessments across Asia-Pacific, including India. NASSCOM data similarly shows Linux administration as one of the top five technical skills demanded in Indian IT job postings for infrastructure and DevOps roles.
How to Change File Permissions in Linux for Cybersecurity Interviews
If you are preparing for a cybersecurity or sysadmin role, expect chmod and chown questions. Interviewers at Indian IT firms like Infosys, Wipro, and TCS regularly test candidates on explaining ls -l output and writing the correct chmod command for a given scenario. The cybersecurity interview preparation guide at 3University covers this and more, with answers framed for technical rounds at Indian and global firms.
According to the 2022 Verizon Data Breach Investigations Report, misconfigured server permissions were a contributing factor in 13% of breaches involving web-facing Linux systems. Getting your permission patterns right from the start is not a theoretical exercise.
Knowing how to give read write permission in Linux is straightforward once you understand the model. For a file, chmod 664 filename gives the owner and group read-write access while keeping others at read-only. For a folder, chmod 775 foldername does the same plus adds execute (directory traversal) for owner and group.
Ready to go from understanding file permissions to building real security skills? 3University’s cybersecurity programs take you from Linux fundamentals to ethical hacking and beyond. Explore the cybersecurity courses at 3University and start building skills that matter in the job market.
Frequently Asked Questions
How do you change file permissions in Linux?
Use the chmod command. You can use symbolic mode, like chmod u+x file.sh to add execute for the owner, or numeric octal mode, like chmod 755 file.sh to set all permissions at once. Add the -R flag to apply changes recursively to a directory and everything inside it.
How do you check the permissions of a file in Linux?
Run ls -l filename to see the full permission string for a specific file, or ls -l in a directory to list all files with their permissions. The output shows the permission string, owner, group, file size, and modification date. You can also use stat filename for more detail including octal representation.
What does chmod 777 mean?
chmod 777 grants full read, write, and execute permissions to the owner, the group, and every other user on the system. It is a serious security risk on any shared or internet-facing server. An attacker who exploits a vulnerability on the server can modify or execute any file with 777 permissions. Use it only in isolated testing environments, never in production.
How do you change the owner of a file in Linux?
Use the chown command. The syntax is chown newowner filename to change just the owner, or chown newowner:newgroup filename to change both owner and group at the same time. You need sudo or root privileges to transfer ownership to another user. Use chown -R to apply changes recursively to a directory.
How do you give read-write permission in Linux?
To give read and write permission to the file owner, use chmod u+rw filename in symbolic mode or chmod 644 filename in numeric mode for owner read-write with read-only for others. To give read-write to both owner and group, use chmod 664 filename. For a folder, replace the filename with the directory name and add -R if needed.
Last updated: July 2026. Reviewed by the 3University editorial team.


