1. Home
  2. Linux
  3. Fix folders not writable by user account in linux

How to fix folders not writable by user account in Linux

Not all of the folders on a Linux-based operating system is writable to the user. There’s a good reason for this: system-level folders require high-level permissions. The problem with these permissions is that often, it locks out user-level access. So, if you’re trying to place files in a system directory and you’re not able to, you’ll need to learn how to change the permissions so that non-root accounts have access.

In this guide, we’ll show you how you can update the permissions of folders on Linux to make them writable by your user account.

Update permissions of folders in terminal

Folder permissions on Linux are most easily updated with the chmod command. Here’s a small list of basic chmod permissions.

  • 7 – read, write, and execute.
  • 6 – read and write.
  • 5 – read and execute.
  • 4 – read-only
  • 3 – write and execute.
  • 2 – write-only.
  • 1 – execute only.
  • 0 – no access.

Each of the numbers in the list works with the Chmod command in groups of three. Here’s an example. To change the permissions of the “test” folder on Linux, so that everyone can read, write, and execute code inside of it. Do:

chmod 777 /test

Additionally, to change the permissions of every single folder inside of the “test” directory, so that it reflects the same permissions, the recursive option must be used. For example

chmod 777 -R /test

Each of the numbers in the Chmod command example above has a purpose. The first number represents the user. The second number sets the permission for the group, and the third set it for the rest of the system.

So, if you’re having issues writing inside of a folder on the system that is not accessible, look to the list above and apply it to the example code below.

chmod XXX

Or, to update all of the folders inside of the top-level one.

chmod XXX -R folder-name

Update ownership of folders in terminal

Sometimes updating the individual permissions of a folder through Chmod is not possible. Sometimes, the user needs to update the ownership of the directory completely.

A good example of times where you’d need to update the ownership of a directory is if you’re dealing with placing website files in /var/www/, manipulating database files, etc.

To change the ownership of any directory on a Linux system, gain root access using the su or sudo -s command in terminal.

su

or

sudo -s

With root access, use the chown example below to change the ownership of a directory entirely.

chown user:user /location/of/directory

Once you’ve run the chown command above, use the ls command along with the “l” switch to check the permissions of the folder, and confirm that it worked.

ls -l /location/of/directory

Update permissions of folders in the file manager

Updating permissions through the file manager on Linux is severely limited compared to doing it with the command-line. However, if you’re not a fan of the terminal, it’s good to know how to do this kind of thing with the file manager.

Gnome/Budgie, etc

Step 1: Open up a terminal window, and use the sudo command to launch the file manager as root.

sudo nautilus

Step 2: Click on the root file manager. Then, find “root file-system” to gain access to the system files on your Linux hard drive.

Step 3: Using the Gnome file manager, look through the file system for the folder you wish to update.

Step 4: Right-click on the folder and select “Properties.”

Step 5: Click on the “Permissions” tab to gain access to the permissions of the folder.

Step 6: Use the permission window to set the folder to whichever permissions you’d like. Then, click the “Change Permissions” button.

Close the “Properties” window, and the permissions should automatically update to the directory.

KDE

Sadly, it is not possible to open up the KDE Dolphin file manager as root easily, due to a software patch. Follow the command-line instructions above to update permissions instead.

Mate

Step 1: Open up a terminal window and run the command below to launch the Mate file manager as root.

sudo caja

Step 2: Click on “filesystem” under the “Devices” column on the left. Then, browse through the root folder for a file you’d like to change the permissions of.

Step 3: Right-click on the folder you’re looking to modify and select “Permissions.”

Step 4: Use the “Permissions” area to set permissions of the folder. Then, click the “Change Permissions” button.

Step 5: Close the “Properties” window.

After closing the “Properties” window, permissions should automatically update.

XFCE

Step 1: Open up Thunar as root by pressing Alt + F2 and typing in the command below into the quick-launcher.

pkexec thunar

Step 2: Enter your user password into the box that appears to access Thunar in root mode.

Step 3: Find “Filesystem root” on the left side-bar and select it to gain access to the root file-system. Using the file manager, find the folder for which you’d like to update permissions .

Step 4: Right-click on the folder and select “Properties.” Then, click “Permissions” to access the permissions window.

Step 5: In “Permissions,” use the window to set the folder permissions. Then, close the window.

With the “Properties” window closed, permission settings should automatically apply.

Generic Linux file managers

There are a lot of different file managers out there. In this section of the guide, we covered the 4 most common ones. If your file manager isn’t covered, consider following the terminal instructions instead.