What is the simplest way to check if file(pdf) got write protection(or not got)?

I am using Ubuntu and not got any solution.

  • Is this a question about PDF encrypton, or are you just asking how to check whether a file is write-protected?
    – user246
    Commented Jun 24, 2014 at 12:26
  • whether a file is write-protected only.
    – SkorpEN
    Commented Jun 24, 2014 at 12:34
  • Which operating system? Command line or API? If API, which language?
    – user246
    Commented Jun 24, 2014 at 13:03
  • command line or ubuntu gui, or web check, does not metter. Simpler seems to check in file properties.
    – SkorpEN
    Commented Jun 24, 2014 at 13:40
  • 1
    What is the context related to sqa/testing? Better question for unix.stackexchange.com Commented Jun 24, 2014 at 18:23

2 Answers 2


You can use from command line ls -l. This lists files in a directory and shows the permissions for the files. The permissions look something like this: -rw-r--r--. 1 user1 users It belongs in this case to the group users and user1 is the owner of the file. The -rw means that the owner has read/write, the group has read and the overall permission for the file is read (anyone outside the group).

More info about understanding permissions in linux: http://www.linux.org/threads/file-permissions-chmod.4094/

  • Seems like the simplest so good. Still I am not sure if pdf not got other locks and how to change them, but I guess it is not that crucial. Thanks.
    – SkorpEN
    Commented Jun 25, 2014 at 8:30

Use a bash script to check if a file is writable. Bash is the default shell under Ubuntu.

Example script from: http://www.cyberciti.biz/faq/unix-linux-shell-scripting-test-if-filewritable/


[ $# -eq 0 ] && exit 1

if [ -w "$FILE" ]
   echo "Write permission is granted on $FILE"
   echo "Write permission is NOT granted on $FILE"

This checks if the file is writable for the current user running the script.

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.