I have chowned the directory like this:

sudo chown -R ubuntu:ubuntu /home/ubuntu/xyz

And then I ran a script which puts files to a directory gives me a permission denied error after some files are put.

The error is as follows:

IOError: [Errno 13] Permission denied: '/home/ubuntu/xyz/some/random/dir/data/outputs/xy.json

It is to be noted that this is like the 13th json file in the list. So, the previous 12 files have already been written successfully to the directory.

Tested this flow multiple times, and the same error occurs midway the process, which I found weird, as some files are being written before it suddenly throws this error.

Where did I go wrong in the file permissions?

It is a Python script, which does:

with open(os.path.join(output_dir,'{0}.json'.format(filename)),'w') as fout:

The error was from the Python script.

Permissions of the directory /home/ubuntu/xyz:

drwxr-xr-x 3 ubuntu ubuntu 4096 Aug  4 05:13

Permissions of the directory /home/ubuntu/xyz/some/random/dir/data/outputs/:

drwxr-xr-x 3 ubuntu ubuntu 4096 Aug  4 05:13
  • if you want to know what is wrong with the file permissions, showing us the permissions of the file might be a good idea... Some information about the environment is also needed. I don't know what program throws an error IOError: [Errno 13] - I've never seen that before. So in what system and context and by what method are you copying the files? – Zanna Aug 4 '17 at 6:43
  • @Zanna Thanks for helping. Updated the post. Let me know if the edit clears things up :) – Dawny33 Aug 4 '17 at 6:50

Your Answer

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

Browse other questions tagged or ask your own question.