RHEL: Permission Denied

If you are getting permission denied when executing files that you believe you have rights to, here are some suggestions. You’ll need sudo access to do the following:

check file ownership:

ls -la

change file ownership:

chown user:group filename

add -R to change directory and everything underneath

check that your files have execute rights.
This is often missing when you upload files from Windows:

ls -la

change rights:

chmod +x filename      
chmod +x -R directoryname

finally, check SELinux context.
SELinux context is often messed up when you use a file transfer tool (ie FTP – FileZilla, SCP – WinSCP) to transfer from Windows to Linux.

ls --lcontext        or         ls -Z

compare your file/directory with other files. If you have no problems executing the other files, use them as the reference context.

chcon -R --reference otherworkingdirectory yourdirectory

Tested on Red Hat Enterprise Linux Server release 6.6 (Santiago)


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s