Search code examples
javalinuxkeytoolrhel7

Running jre keytool results in the Permission Denied error


I have a script running the command:

/tmp/jre1.8.0_131/bin/keytool -import -trustcacerts -file '/etc/pki/ca-trust/source/anchors/company.crt' -keystore '/tmp/jre1.8.0_131/lib/security/cacerts' -storepass changeit

Got the error:

bash: /tmp/jre1.8.0_131/bin/keytool: Permission denied

Checked all permission on the directories and keytool – all are executable.

I am at RHEL-7


Solution

  • A lot of Distributions do not allow files to be executed from within the /tmp directory.

    Either move the jre out of /tmp (why is it even in there?) or make it executable via:

    sudo mount -o remount,exec /tmp