The chmod command controls file permissions in Linux. The execute permission allows users to run scripts and programs. This guide shows how to use chmod executable to manage these permissions.

Apply the command with mode 755 to a file:

$ chmod 755 script.sh

The breakdown shows owner with full access, group with read and execute, and others with read and execute.

Syntax of the chmod Command

chmod [options] [mode] [file_name]

The mode represents permissions as a three-digit number or symbolic notation like u+x. The file_name identifies the target file or directory.

Common Permission Modes

Mode Owner Group Others Use Case
700 rwx Private scripts only you can run
750 rwx r-x Team-only executable
755 rwx r-x r-x Everyone can run, owner edits
775 rwx rwx r-x Group collaboration
Note: The recursive flag -R applies chmod executable permissions to all files in a directory structure.

Permission Types in Linux

Linux assigns three permission types to each file. Read allows viewing contents. Write enables modifications. Execute lets users run the file as a program.

Each permission applies to three categories: owner, group, and others. The owner created the file. The group includes members with shared access. Others represents all remaining users.

Using Octal Notation

Octal mode uses numbers to represent permissions. Each digit corresponds to a permission level.

Value Permission Binary
4 Read 100
2 Write 010
1 Execute 001

Add values together for combined permissions. The value 7 grants all permissions (4+2+1). The value 5 grants read and execute (4+1).

Grant the owner full access, group read and write, and others read only:

$ chmod 764 document.txt

Using Symbolic Notation

Symbolic mode uses letters instead of numbers. The format combines who, action, and permission.

Categories include u for user, g for group, o for others, and a for all. Actions include + to add, - to remove, and = to set exactly.

Add execute permission for the owner:

$ chmod u+x script.sh

Remove write permission from others:

$ chmod o-w file.txt
Tip: Use symbolic notation for single permission changes and octal notation when setting multiple permissions at once.

Reverting Permission Changes

Reset permissions by applying the correct mode again. Check current permissions first with ls -l.

Restore standard file permissions (owner read-write, others read-only):

$ chmod 644 file.txt

Making Scripts Executable in Linux

Scripts require execute permission to run. Without this permission, Linux blocks execution. Follow these steps to make a script executable.

Step 1: Navigate to the Script Directory

Move to the directory containing your script:

$ cd /path/to/script

Step 2: Check Current Permissions

View existing permissions with the ls command:

$ ls -l script.sh

The output displays permissions in the first column. Look for the x character in the permission string.

Step 3: Add Execute Permission

Apply the chmod executable command to the script:

$ chmod +x script.sh

This adds execute permission for all users. For owner-only execution, use:

$ chmod u+x script.sh
Warning: Granting execute permission to all users on system files creates security risks. Apply permissions carefully.

Step 4: Verify the Changes

Confirm the permission change worked:

$ ls -l script.sh

The permission string now shows x in the execute position.

Step 5: Run the Script

Execute the script using the current directory notation:

$ ./script.sh

The dot-slash prefix tells Linux to look in the current directory for the file.

Practical Applications

Apply chmod executable to automation scripts that run scheduled tasks. Set mode 700 for scripts containing sensitive operations.

For shared team scripts, use mode 750. This allows team members to execute while preventing modifications from unauthorized users.

System-wide utilities need mode 755. This grants universal execute access while restricting modifications to the owner.

Note: Verify script functionality in a test environment before applying chmod executable permissions in production.

FAQs

The chmod +x command adds execute permission to a file for all users. This allows the file to run as a program or script directly from the terminal.

Use chmod u+x filename to add execute permission only for the owner. This restricts script execution to the file owner while blocking group members and others.

Run chmod -x filename to remove execute permission from all users. For specific categories, use chmod u-x, chmod g-x, or chmod o-x for owner, group, or others.

Mode 755 gives full access to owner, read-execute to others. Mode 777 grants full access to everyone. Avoid 777 as it creates security vulnerabilities on systems.

Yes, execute permission on directories allows users to access the directory contents. Use chmod +x directory_name or apply recursively with chmod -R +x to all subdirectories.

Willie has over 15 years of experience in Linux system administration and DevOps. After managing infrastructure for startups and enterprises alike, he founded Command Linux to share the practical knowledge he wished he had when starting out. He oversees content strategy and contributes guides on server management, automation, and security.