0

It is true that i may not have understood how umask calculations work.

This query is just for a test case (my learning).

My intention is that my process should generate a file pdf file1.pdf with full permission 777 however, it generates a maximum of 666 permissions only.

#!/bin/bash
export umask=111;
echo "Tomcat is starting .... "
 rm file1.pdf
 umask 111
 echo "Hello" >file1.pdf
 echo "Tomcat started"

Output post run:

root@6b5c5e56c544:/tmp/exersize# ls -ltr file1.pdf
-rw-rw-rw- 1 root root 6 Aug  5 15:22 file1.pdf

Can you please explain as a layman why cant I set file permissions to 777 and how I can?

Ashar
  • 491
  • A plain pdf file does not need execute bit. Is there a reason for you to add x permission to the pdf file? Also, you'll need to set umask to 000. – unxnut Aug 05 '22 at 15:34
  • umask doesn't control the permissions bits. The process that creates the file requests the permissions, and the umask can force some of the bits off. However, umask can't force any of the bits on. You can have a umask value of 000 which allows all permissions bits to be on, but if the process doesn't request some of the bits on, they won't be on. – Sotto Voce Aug 05 '22 at 16:09

0 Answers0