Low Orbit Flux Logo 2 D

Linux How To Execute A File

Executing a file in Linux is pretty straight forward. The only real complication is when you don’t have permission but that is an easy fix too.

Lets use the script “test1.sh” as an example. This first example will work basically the same to run either a script or a binary executable. To run this script you would do the following assuming that you are in the same directory. This will execute the script.


To run a script, the user running it will need to have both read and execute permissions.

You can add both permissions using either of these commands. The difference is that the first one gives permission to the owner of the script. If that is you, then you should be all set. If not you can also add permissions to either the group or to everyone. If you aren’t sure or just don’t care, then just assign permissions to everyone.

chmod u+rx test1.sh   # add permission for owner
chmod g+rx test1.sh   # add permission for the group
chmod a+rx test1.sh   # add permissions for everyone

You don’t necessarily have to grant these permissions to execute a file if it is a script. Here is an example showing how you could run both a BASH script and a Python script that may not have execute permissions. You will still need read permissions though.

bash test.sh 
python test.py