Change folder permissions and ownership from command line

This post shows how to change permission and ownership from command line on Linux OS.

Use chown to change ownership and chmod to change permission.

The -R option makes them change the permissions and ownership for all files and directories inside of the given directory.

The following command will change ownership (both user and group) of all files and directories inside your_directory and including your_directory itself:

$ sudo chown -R username:group your_directory

And the following command will only change the permission of the folder directory but will leave the ownership of the files and folders inside the directory not changed:

$ sudo chown username:group your_directory

Note that you need to use sudo to change the ownership from root to yourself.

To make the current user own everything inside the folder (and the folder itself), use the following command:

$ sudo chown -R $USER your_directory

$ sudo chown -R $USER:$USER your_directory

For more commonly used Linux commands, check my other posts at here  and here .

Leave a Reply

Your email address will not be published. Required fields are marked *