How to Give User Write Access to Folder in Ubuntu

If you want to allow a user to write, read, and execute files in a folder in Ubuntu, you need to change the permissions and ownership of that folder. In this tutorial, you will learn how to do that using the terminal and the graphical user interface.

Prerequisites

Before you start, you need to have the following:

  • A computer running Ubuntu with root or sudo privileges.
  • A folder that you want to give write access to.
  • A user that you want to grant write access to.

Step 1: Identify the Owner and Group of the Folder

The first step is to identify the owner and group of the folder that you want to give write access to. This will help you decide how to change the permissions and ownership of the folder. To do this, open a terminal and run the following command:

ls -l /path/to/folder

Replace /path/to/folder with the actual path of the folder. You will see an output like this:

drwxr-xr-x 2 root root 4096 Dec  6 10:17 folder

The output shows the permissions, owner, group, size, date, and name of the folder. In this example, the owner and group are both root.

Step 2: Add the User to the Group

The next step is to add the user that you want to give write access to the group of the folder. This will allow the user to inherit the permissions of the group. To do this, run the following command:

sudo usermod -a -G groupname username

Replace groupname with the actual group of the folder, and username with the actual user that you want to add. For example, if you want to add the user alice to the group root, run this command:

sudo usermod -a -G root alice

You may need to log out and log in again for the changes to take effect.

Step 3: Change the Permissions of the Folder

The final step is to change the permissions of the folder to give write access to the group. To do this, run the following command:

sudo chmod g+w /path/to/folder

Replace /path/to/folder with the actual path of the folder. This command will add the write permission (w) to the group (g) of the folder. You can also use the -R option to apply the changes recursively to all the files and subfolders inside the folder.

Step 4: Verify the Permissions

To verify that the user has write access to the folder, run the following command:

ls -l /path/to/folder

You should see an output like this:

drwxrwxr-x 2 root root 4096 Dec  6 10:17 folder

The output shows that the group now has write permission (w) to the folder. You can also try to create, modify, or delete a file inside the folder as the user that you added to the group.

Conclusion

You have successfully given user write access to a folder in Ubuntu. You can use the same steps to change the permissions and ownership of any folder or file in your system. For more information about file permissions and ownership in Linux, you can visit the official documentation or the Ask Ubuntu website.

What are your feelings
Updated on December 12, 2023