3

What are reasonable PDF file permissions?

Lately I've found that inside a directory, with many PDF files, all files have all possible permissions set on. Being uncomfortable with that I thought about changing them. However, I don't know what be reasonable for PDF files considering that I want to be able to open and, sometimes, change them (e.g. PDF "text maker").

Here a print-screen for how I've found them (file_1.pdf), and how I consider to change them(file_2.pdf).

This is an example for how (file_1.pdf) I've found them, and how I consider to change them(file_2.pdf)

I suppose that the initial permission set was lost while I've copied them from a backup HDD. Could you please consider example-peaking a effective way of copying them around without loosing their permission settings. Thank you.

2
  • 2
    No, you don't need execution permission. Does your backup hdd have FAT partition, maybe?
    – jimmij
    Jan 20, 2018 at 21:03
  • @jimmij Thank you. It was a NTFS formatted HDD. Kusalananda & Hauke Laging seem to pointed the right reason for the situation.
    – alex
    Jan 21, 2018 at 15:56

3 Answers 3

3

If you copy from and to a Linux file system then you use

cp -a

for keeping the metadata.

If you are copying back from a non-Linux file system like FAT or NTFS then you can use

cp -r --no-preserve=mode

so that the execute permission is dropped.

If you copy files to a non-Linux file system then you should use a Linux archive tool like tar.

2
  • Thank you very much! Your answer gives the most and key background information -- FAT/NTFS HDDs -- and how to avoid the problem. However you are not answering directly the question about PDF permissions. Therefore only the up-vote.
    – alex
    Jan 21, 2018 at 16:03
  • @alex I did not mention that because the other answer already did and I did not want to repeat that. However, I do not care much about my answers getting accepted anyway so no problem. Jan 21, 2018 at 16:20
2

No, a PDF file is not an executable binary or script and should never need to be executable.

Assuming the documents live on a Unix filesystem, you may remove the executable bits using

chmod a-x *.pdf

If some of your file systems are non-Unix file systems, the permissions on your files may be messed up like this regardless of how you copy the files around between them. On Unix file systems, I tend to use rsync -a (or rsync --archive) to copy files between hosts or local directories to preserve permissions and timestamps.

1
  • 1
    With the help of @AlikElzin-kilaka 's answer from StackOverflow it was possible to change all PDF files' permissions of all subdirectories by using following (Debian Stretch) bash terminal command in one step: find . -name "*.pdf" -type f -exec chmod 644 {} \;
    – alex
    Jan 21, 2018 at 17:42
1

Read only permission is normally ok, if you only need to read them. However, if you want to modify and replace them, you need also write permission. Therefore I would consider the permission of the second file as sufficient.

For copying the files and keep the permissions use: "cp -a source dest"

The "-a" attribute copies recursive, preserves all attributes and preserves links. See "man cp".

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .