Prerequisite: Check Current Linux File Permissions
Before you can make a file executable, it is recommended to check theLinux permissionsfor the file. Use the ls command to check the privileges allowed for the file:
For example, we used the command below to check the permissions for the file test.sh.
The first nine characters in the output show the permissions on the file. Here, r stands for read and x stands for executable.
In Linux, to change a file’s permissions for different users we use thechmod command. For instance, you can use the chmod command to make a file executable for all users or allow only users of a group to read the file.
To make the file executable for all users in your Linux system, use this syntax:
OR
For example, to make the file test.sh executable for all users, use this command:
OR
The owner refers to the user who creates the file in Linux systems. To make the file executable for only the owner of the file on the same Linux system, use the following syntax:
For example, use this command to make the file executable only for the owner:
A group refers to a collection of users having a specific purpose. Here’s the method to grant executable access in Linux to a group with the chmod command:
For example, to make a file named test.sh executable, use this command:
To make a file executable for every other user on a Linux machine, use this command:
For example, use this command to make the file test.sh executable for every other user except owner and group members:
Though the command line method works the fastest and without a hassle, the GUI method is more common among beginners. DifferentLinux distributionscome with different “Desktop Environments”, but the process to make a file executable is pretty much the same:
Navigate to the file and select the file.
Right-click on the file name and select the Properties option. Alternatively, press CTRL + i on the keyboard. This will open a new “File Properties” window.
Click on the permissions tab.
Check the box at the bottom which says “Allow executing the file as program”.
Note: The GUI method can only make the file executable for all users in Linux. You will need to rely on the command line methods described above if you wish to selective with permissions.
Bringing the latest in technology, gaming, and entertainment is our superhero team of staff writers. They have a keen eye for latest stories, happenings, and even memes for tech enthusiasts.