I'm having a problem with file permissions... Iv'e got a python program to automatically take pictures using fswebcam (by running a bash script using subprocess.call). however when i try to delete these files from my mac (SSH) (or even from the pi command line rm -r without sudo) i dont have permission.

if i run the fswebcam command myself i can delete it.

when created with the script it is owned by root (in group pi) and owned by pi if i run it (and in group pi). Even when i chmod the file to 777 i cannot delete it.

Any solutions?

EDIT: The permissions for the containing folder is drwxr-sr-x. This folder is created using os.mkdir("folder_name"), how do i stop this from creating the folder as both setuid bit and execute bit?

  • Check the ownership and permissions of the directory. Deleting a file requires permission to modify the directory.
    – Craig
    Commented Feb 24, 2014 at 19:07
  • The directories permissions are: drwxr-sr-x. I dont know what the 's' is :/ These created using os.mkdir("folder_name").
    – Waddas
    Commented Feb 24, 2014 at 20:17
  • Do you have any dmask bits or umask bits set in your fstab file? How is your drive(s) mounted? Commented Feb 25, 2014 at 0:45

1 Answer 1


Most likely the files are owned by the user running the python script. My guess is that you are probably running that as root?

when doing an ls -l you will see the permission bits, owner and group.


ls -l


-rwxr--r--   1 root wheel  278 Nov 20 13:22 derp.sh

this means that the file 'derp.sh' is owned by the user "root". "wheel" is the group in this case.

-rwxr--r-- can be split up in 3 parts: owner - group - other like so:

  • | rwx | r-- | r-- We can ignore the first "-" here.

(Other means anyone that doesn't match the owner or isnt in the group)

R means READ

W means WRITE


so in this example:

Root is the owner of the file and can read write and execute this file.

Anyone in the wheel group can read this file.

All other users can also read this file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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