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.
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It only takes a minute to sign up.
Sign up to join this communityWhat is the simplest way to check if file(pdf) got write protection(or not got)?
I am using Ubuntu and not got any solution.
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/
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/
#!/bin/bash
FILE="$1"
[ $# -eq 0 ] && exit 1
if [ -w "$FILE" ]
then
echo "Write permission is granted on $FILE"
else
echo "Write permission is NOT granted on $FILE"
fi
This checks if the file is writable for the current user running the script.