0 0 Votes

Linux: Mark program file as executable

Tutorial by Stefan Trost | 01/01/2018 at 16:11

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.

Of course, those who are always using the Software Center or other Linux package managers 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

Under 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. 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. 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".

ReplyPositiveNegative

About the Author

Avatar AuthorYou 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 | Message

 

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.

Participate

Ask your own question or write your own articles on askingbox.com. How to do.