In a bid to automate backup processes, the xFusionCorp Industries sysadmin team has developed a new bash script named xfusioncorp.sh. While the script has been distributed to all necessary servers, it lacks executable permissions on App Server 1 within the Stratos Datacenter.
Your task is to grant executable permissions to the /tmp/xfusioncorp.sh script on App Server 1. Additionally, ensure that all users have the capability to execute it.
Check the current file permission status:
ls -la /tmp
4 ---------- 1 root root 40 Jul 30 02:21 xfusioncorp.sh
Run the following command to update permissions:
chmod 755 /tmp/xfusioncorp.sh
Verify the results:
ls -la /tmp
4 -rwxr-xr-x 1 root root 40 Jul 30 02:21 xfusioncorp.sh
chmod in LinuxThe chmod command in Linux is used to change the permissions (mode) of a file or directory. File permissions determine who can read, write, or execute a file.
Each file in Linux has three types of permissions:
Permissions are set for three categories of users:
Each of these categories can have its own combination of r, w, and x.
Two Ways to Use chmod
Symbolic Mode Use letters to set permissions:
chmod u=rwx,g=rx,o=r test.sh
This sets:
You can also use +, -, or =:
+ adds permission- removes permission= sets exact permissionExample:
chmod g+w test.sh # Add write permission for group
chmod o-r test.sh # Remove read permission for others
Numeric (Octal) Mode Each permission is represented by a binary digit:
You sum them up per category and write a 3-digit number:
chmod 754 test.sh
Breakdown:
| Role | Symbol | Permissions | Value |
|---|---|---|---|
| User | u | rwx | 7 |
| Group | g | r-x | 5 |
| Others | o | r– | 4 |
This system gives you fine-grained control over who can access your files and how they can interact with them.