When you start managing a Linux computer or cloud server, you will frequently see messages like "Permission denied". Do not panic! Linux is built from the ground up as a multi-user system, and permissions are simply security guards that decide who can read, edit, or run files.

The Three Magic Roles (UGO)

Every file in Linux checks three categories of people whenever someone tries to touch it:

  • User (u): The person who owns the file.
  • Group (g): A team of users who share access.
  • Others (o): Everyone else in the world.

The Three Basic Permissions (rwx)

For each of those roles, Linux assigns three possible permissions:

  • Read (r): Look at what is inside the file.
  • Write (w): Modify, save changes, or delete the file.
  • Execute (x): Run the file like a program or script.

Checking Permissions with ls -l

Type this command in your terminal to inspect the permissions of your files:

# List files with full permission details
ls -l myfile.txt

You will see something like -rw-r--r--. The first rw- means the owner can read and write; the next r-- means group members can only read; and the final r-- means others can only read.

Changing Permissions with chmod

The command chmod stands for change mode. If you want to make a script executable so you can run it, simply use the plus (+) sign:

# Add execute permission to your script
chmod +x run.sh

# Now you can run it easily
./run.sh

Changing Ownership with chown

If you want to transfer ownership of a file to another user, use chown (change owner):

# Make the user 'bagus' the owner of the document
sudo chown bagus document.txt

3 Things to Remember

  • Roles: Linux tracks permissions for User (owner), Group, and Others.
  • chmod: Use chmod +x filename to make a script runnable.
  • chown: Use chown username filename to change who owns the file.