I've a file in /var/ folder which is created by www-data application. Ownership and permission of the file is,

-rw-r--r--  1 www-data www-data   74214 Feb 18 17:00 sample.pdf

I tried to access this pdf by using non sudo user.

pdftk /var/myproj/www/sample.pdf

It gives me the error,

Unable to find file.
Error: Failed to open PDF file: 

For the sake, I've changed the permission to '777' and tried to access the same again.

-rwxrwxrwx  1 www-data www-data   74214 Feb 18 17:00 sample.pdf

This time also I'm getting the same error. I have changed that directory permission also to 777. But It gives me the same error why? My ubuntu version is '18.04'.

  • Unable to find file makes me think the file just isn't located where you expect it to be. Please edit your post and add the output of ls -ld /var /var/myproj /var/myproj/www /var/myproj/www/sample.pdf. – PerlDuck Feb 18 at 13:34

I believe you need to set the permission on that specific file. And I do not recommend setting those permission on a folder, it is very insecure

So it would be

chmod 777 /var/myproj/www/sample.pdf

There is also a chance you don't own the file, so

chown your-user /var/myproj/www/sample.pdf

Please note that certain application will automatically rechange permissions back to default, and sudo is usually needed to change file permissions.

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.