In Linux operating systems, security is enforced through file permissions. Each file has permission bits grouped into three sets of owners: Owner (user), Group, and Others (all other users). Each set can have Read (r), Write (w), and Execute (x) privileges.
For a shell script (e.g., a Bash script) to run successfully, two conditions must be met:
x): The operating system must be allowed to execute the file as a program.r): The shell interpreter (e.g., /bin/bash) must be able to open and read the commands written inside the script to execute them.A common system administration pitfall is granting only execute permissions (chmod +x) while leaving read permissions restricted. This leads to a Permission denied error when standard users attempt to run the script, because the interpreter cannot read the command sequence inside the file. To make a script universally executable, it must be given both read and execute permissions for all users (r-x).
This guide details the steps to modify file permissions on /tmp/xfusioncorp.sh using both symbolic and numeric (octal) notation, and verify successful script execution.
stapp01, stapp02, stapp03)tony, steve, banner)/tmp/xfusioncorp.shr-x) for all users (Owner, Group, and Others)SSH into the assigned application server from the Jump Host:
# Example for App Server 1
ssh tony@stapp01
Locate the script and inspect its current owner, group, and permissions using the long listing command:
ls -l /tmp/xfusioncorp.sh
Example starting output showing restricted permissions:
-r-------- 1 root root 128 Jun 27 11:30 /tmp/xfusioncorp.sh
(In this example, only the root owner can read the file; no other users have read or execute access.)
To allow all users to read and execute the script, use the chmod utility. You can apply this using either symbolic or numeric mode:
Add read (r) and execute (x) permissions to all (a) users:
sudo chmod a+rx /tmp/xfusioncorp.sh
Alternatively, you can target specific categories: sudo chmod u+rx,g+rx,o+rx /tmp/xfusioncorp.sh.
Assign 7 (read, write, execute) to the owner, and 5 (read, execute) to the group and others:
sudo chmod 755 /tmp/xfusioncorp.sh
Verify that the permission bits have been updated correctly:
ls -l /tmp/xfusioncorp.sh
Expected output structure:
-rwxr-xr-x 1 root root 128 Jun 27 11:30 /tmp/xfusioncorp.sh
The permission string rwxr-xr-x confirms:
rwx (read, write, execute)r-x (read, execute)r-x (read, execute)Attempt to execute the script directly from the shell path:
/tmp/xfusioncorp.sh
Or navigate to /tmp and run it:
cd /tmp
./xfusioncorp.sh
If the permissions are correct, the script should execute successfully and output its designated text or side-effect without throwing a Permission denied error.
Log out of the Application Server to return to the Jump Host:
exit