Change permissions recursively in Linux or BSD

Written by
Date: 2015-05-29 22:00:32 00:00

How to change permissions for a folder recursively

If you want to changes permissions for all files and folders recursively for Owner, Group and others there is an easy way to do it.

Let’s say you want a folder to be Read and Write for Owner and Group.

sudo chmod -R ug+rw /some/folder

The meaning for this command is:

sudo
Just in case you need to act the root user, if you are the owner of the folder where you are working there is no need to use sudo.
chmod
The command to change permissions to a file or folder
-R
Tells the command to act recursively
ug
This means _u_ser and _g_roup.
+rw
This adds _r_ead and _w_rite permissions to files.

Now if you want to give all permissions for all users.

chmod ugo+rwx /some/file

As you can see ugo means _u_ser, _g_roup, and _o_ther and rwx is for _r_ead, w_rite and e_xecute.