How to Change File Permissions in Ubuntu

The Access Control Vector

The Linux operating system is built on a foundation of strict, multi-user security. Every single file on an Ubuntu server possesses a granular permission matrix determining exactly who is allowed to read it, write data to it, or execute it as a program. If you download a custom bash script from the internet, the kernel will refuse to run it by default as a safety precaution. You must manually modify the file’s permission matrix to grant the “execute” privilege before the script can function.

How to Change File Permissions

Ubuntu relies on the highly mathematical `chmod` (change mode) command-line utility to manipulate these access control lists.

1. Open your terminal application or connect to the server via SSH.
2. The Verification Phase: First, you should look at the current permissions. Type `ls -l` and press Enter. You will see a string of characters next to your file looking something like `-rw-r–r–`. (This means the owner can read/write, but everyone else can only read).
3. The Symbolic Execution (The Easiest Method):
* To modify permissions, you use `chmod`.
* To grant the execute (`x`) privilege to the user/owner (`u`), type the following command:
chmod u+x my_script.sh
* If you want to grant the write (`w`) privilege to all users (`a`), type:
chmod a+w public_document.txt
4. The Numeric Execution (The Advanced Method):
* System administrators frequently use an absolute octal numbering system to define permissions instantly (4 = Read, 2 = Write, 1 = Execute). You add these numbers together.
* For example, 7 (4+2+1) grants full Read/Write/Execute access.
* To grant the owner full access (7), the group read/execute access (5), and everyone else zero access (0), you would type:
chmod 750 secure_script.sh
5. Press Enter. If successful, the prompt will return blank. Run `ls -l` again to verify the permission string has updated.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.