Downloaded open JDK tar.gz file from https://jdk.java.net/15/. When I expand this file with command tar -xf openjdk-15.0.2_linux-x64_bin.tar.gz on one box permissions look like

drwxr-xr-x  2 me me 4.0K Feb 17 15:57 bin

On the other hand when same file, copied to other box and expanded with same command

drwxr-x---  2 me me 4.0K Feb 17 16:37 bin

Same applies to other files in bin directory - no one except myself who expanded the file has execute permissions. As a result I am not able to execute any of the java commands as a different user.

Both machines are Ubuntu 20.04. What could be causing the difference?

  • Are you executing the command as root, or as a non-privileged user? what is the umask in each case? – steeldriver Feb 18 at 18:55
  • @steeldriver I am executing command as myself. I have sudo permissions on both boxes, but to expand the file, I did not use sudo. How do I check umask? – user871199 Feb 18 at 18:56
  • ... if you are using a bash shell, just type umask – steeldriver Feb 18 at 18:58
  • On machine where it works, umask in 0022, where it fails, it's 0027. – user871199 Feb 18 at 19:01

As noted in man tar, when you extract an archive using tar as an unprivileged user, the default behavior is to apply the invoking user's umask to the extracted file permissions:

          Apply  the user's umask when extracting permissions from the ar‐
          chive (default for ordinary users).

In particular, a umask of 0027 removes all permissions for others, whereas 0022 removes only write 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.