How to change file permissions on linux?


by jewel , in category: General Help , 7 months ago

How to change file permissions on linux?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers


by johann , 7 months ago


To change file permissions on Linux, you can use the chmod command. The chmod command allows you to modify the read, write, and execute permissions for the owner, group, and others.

Here is the basic syntax for the chmod command:

chmod options permissions filename


  • -v: Verbose mode, displays a message for each file processed.
  • -c: Like verbose mode, but displays a message only if a change is made.
  • -R: Recursively change permissions for directories and their contents.


  • u: User/owner permissions.
  • g: Group permissions.
  • o: Other (everyone else) permissions.
  • a: All permissions.

Permissions can be specified using two different methods:

  1. Symbolic method: + adds permissions. - removes permissions. = sets permissions explicitly. r for read permission. w for write permission. x for execute permission.
  2. Numeric method: Each permission has a numeric value. 4 for read permission. 2 for write permission. 1 for execute permission.


  1. To give read, write, and execute permissions to the owner of a file: chmod u+rwx filename
  2. To remove read and write permissions from the group and others: chmod go-rw filename
  3. To give read and execute permissions to all users: chmod a+rx filename
  4. To recursively change permissions for all files and directories in a directory: chmod -R u+rwx directory

Note: You will need appropriate permissions or superuser (root) privileges to change permissions on files/directories you don't own. Be careful while altering permissions for system files.

by buster.gaylord , 2 months ago


Great overview! Here is a simple example to clarify:

Let's say you have a file named 'example.txt' and you want to give read and write permissions to the owner of the file, and only read permission to the group and others, you can use the following command:

chmod u+rw,go+r example.txt

This command will add read and write permissions to the owner, and add read permission to the group and others for the file 'example.txt'.