Using Raspbian Buster, I have 2 users, The root user (pi) and a user I setup (polysense). I have a script that runs at startup that is owned by the root user. Part of the script is that it writes to a file on the polysense account. However I am getting a permissions error when the script runs. I tried: sudo chmod 777 configSite as configSite is the folder that contains the files I need to write to.

When I view the permissions, it does not change. What am I doing wrong here? I am expecting to see drwxr-xr-rwx for the files inside configSite.

pi@polysensesolutions:~ $ cd /home/polysense/
pi@polysensesolutions:/home/polysense $ sudo chmod 777 configSite
pi@polysensesolutions:/home/polysense $ cd configSite
pi@polysensesolutions:/home/polysense/configSite $ ls -l
total 164
-rw-r--r-- 1 root      root        1985 Sep 17 04:25 '>'
drwxr-xr-x 3 polysense polysense   4096 Sep  2 16:33  configSite
-rw-r--r-- 1 root      root      143360 Sep 17 04:25  db.sqlite3
-rwxr-xr-x 1 polysense polysense    630 Sep  2 15:51  manage.py
drwxr-xr-x 4 polysense polysense   4096 Sep  2 16:34  pages
drwxr-xr-x 2 polysense polysense   4096 Sep 17 04:12  templates
drwxr-xr-x 4 polysense polysense   4096 Sep 17 04:25  wifiApp
  • sudo chmod 777 configSite you're changing permissions of the directory configSite, but it doesn't mean files inside configSite will be changed. If you want to change permissions of everything inside configSite, you need to add option -R to chmod
    – pavelsaman
    Sep 23, 2019 at 11:13

2 Answers 2


Then you run chmod 777 directory, then only the permissions of the directory itself are changed, not the files contained within it.

If you want to change the permissions of all the files contained in a directory, including those in subdirectories and those subdirectories themselves, use:

chmod -R 777 directory

The -R invokes recursive mode.

Note that it's usually not wise to give more permissions than necessary. Regular files usually should not have execute permissions, as then those could accidentally be called by bash and have the (non-shell command) contents be fed into bash.

If you want to only set the permissions on directories within a given directory, you need to combine chmod with find. First use find to locate all the directories, and then run chmod on those:

find directory -type d -exec chmod 777 {} +

The -type d searches for directories.

The -exec indicates that a command should be run on the found filenames.

The {} is replaced by the found name. The + indicates that multiple names may be replaced into the command line before it is executed.

You also have a file called > which sounds like an error somewhere in a script...


You are changing the permission of the folder, not of the files within. Instead, try

sudo chmod -R 777 configSite/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.