The Access Restriction Vector
The Linux operating system is built entirely upon a rigid, unyielding hierarchy of file permissions. Every single file and directory possesses a mathematical matrix dictating exactly who is allowed to read it, who is allowed to edit it, and who is allowed to execute it as a program. If you download a bash script from the internet, Ubuntu will explicitly deny you the ability to run it until you manually intervene and modify the file’s permission matrix to grant execution rights.
How to Change File Permissions
You must utilize the chmod (change mode) command, which manipulates the underlying permission bits using either symbolic letters or absolute octal numbers.
1. Open your terminal application or connect to your server via SSH.
2. Navigate to the directory containing the target file using the `cd` command.
3. The Symbolic Method (Easiest to Understand): If you simply want to make a script executable for the current user, use the symbolic method. Type the following command and press Enter:
chmod +x script_name.sh
(The `+x` explicitly adds the “eXecute” permission to the file).
4. The Octal Method (Absolute Control): If you are configuring a web server and need to set precise, three-digit permissions (Owner, Group, Others), you must use the numerical method. For example, to grant the Owner full read/write/execute power (7), the Group read/execute power (5), and deny Others all access (0), type:
chmod 750 secure_file.txt
5. Verification: To confirm the kernel has accepted your modification, execute the long-list command:
ls -l secure_file.txt
Look at the far left column of the output. If the string looks like `-rwxr-x—`, your modification was successful (the `r` is read, `w` is write, and `x` is execute).