13 Votes

Linux: Mark Program File as executable

Tutorial by Stefan Trost | Last update on 2021-05-17 | Created on 2018-01-01

Many who are not familiar with the Linux world and who are used to run programs only from Windows are surprised when a program or batch script is not immediately opened and executed after a double-click from a folder or a call from the terminal.

Those who are always using the Software Center or other Linux package managers for installing applications will not often be confronted with these problems, because in these cases, Linux and its system administration take care of everything concerned. Therefore, the following steps are usually necessary only if the programs come from other sources or if you want to start your own programs.

Typical Error Messages

Typical error messages are "Could not display ProgramName", "There is no application installed for executable files" or "Permission denied" in the terminal.

Make the Program executable

On Linux, each file has rights for certain user groups. For example, "r" (read) if a file can be read by a user group or "w" if a file can be written to or changed by a group (write). If you enter "ll" into the terminal, you will typically see all these flags in front of the file name.

The flag "x" (executable) marks a file that is executable. If we try to execute a program file that does not have an x-flag for its own user group, the above error messages will appear instead of executing the application.

With the command "chmod" (Change Mode) we can simply set the x-flag of a file from the terminal:

sudo chmod +x ProgramName

To do this, we need to navigate to the appropriate program file in the terminal and then we can enter "sudo chmod +x" followed by the name of the program file. Since root privileges are required for this process, we must preface the command "sudo" and then enter our password to execute the command.

The "+x" causes the "x" flag to be added to the file flags. Likewise, the flag can be removed again using "-x". Correspondingly, we can change the read and write permissions/rights of a file via "+r", "-r", "+w" or "-w".

Alternatively, we can also click on the file with a right click and make the appropriate settings under Properties > Permissions from the file info dialog.

Run Program

After marking the application file as executable, it can be easily opened from a folder with a simple click or a double-click  (depending on the system) or from the console/terminal with the command "./ProgramName".


About the Author

AvatarYou can find Software by Stefan Trost on sttmedia.com. Do you need an individual software solution according to your needs? - sttmedia.com/contact
Show Profile


Related Topics

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.


Ask your own question or write your own article on askingbox.com. That’s how it’s done.