Running an executable file in Linux means telling the system to start a program you have stored on your computer
An executable file is a program that your computer can run directly. In Linux, these files are usually marked with a small x symbol when you list them, and they often have no file extension at all — or sometimes end in .sh, .bin, or .run. To run one, you need to tell Linux where the file is and confirm you want to start it. The method depends on whether you are using the terminal or a graphical file manager, and whether the file is in your current folder or somewhere else on your system.
The simplest way is to type the file's path into the terminal and press Enter. If the file is in the folder you are already in, you type ./filename (the dot and slash mean "in this folder"). If it is somewhere else, you type the full path, like /home/username/Downloads/myprogram. Linux will then run the program when ready.
Key Takeaways
- Executable files in Linux are marked with an x symbol and can be run from the terminal by typing ./ followed by the filename if the file is in your current folder.
- If a file is not marked as executable, you must change its permissions first using the chmod command before you can run it.
- The ./ prefix tells Linux to look for the file in your current directory rather than searching your system's program folders.
- You can also double-click executable files in your graphical file manager if they are marked as executable and your system is configured to allow it.
- Some programs run in the background and return control to the terminal when ready; others stay open until you close them or press Ctrl+C.
Running a file that is already in your current folder
Open your terminal and navigate to the folder where your executable file is stored. You can see what folder you are in by typing pwd and pressing Enter — this shows your current path. Once you are in the right folder, type ./ followed by the exact filename. For example, if your file is called setup, you would type ./setup and press Enter.
The ./ is important because it tells Linux to look for the file in your current directory, not in the system's standard program folders. Without it, Linux will search your PATH (a list of folders where system programs live) and may not find your file. After you press Enter, the program will start running.
Running a file from a different folder
If your executable file is not in your current folder, you can type the full path to it. For example, if the file is in your Downloads folder, you might type /home/username/Downloads/myprogram and press Enter. Replace username with your actual username, and myprogram with the real filename.
You can also use a shortcut: the tilde symbol (~) represents your home folder. So ~/Downloads/myprogram is the same as typing out /home/username/Downloads/myprogram. This is faster and works no matter what your username is.
Checking and changing file permissions
Before you can run a file, it must be marked as executable. If you try to run a file and get an error saying "Permission denied", the file does not have execute permission yet. To check a file's permissions, type ls -l filename and press Enter. You will see a line of letters and dashes at the start — if there is an x in that line, the file is executable. If there is no x, you need to add execute permission.
To make a file executable, type chmod +x filename and press Enter. The chmod command changes permissions, the +x means "add execute permission", and filename is the name of your file. After you run this command, the file is ready to run. You only need to do this once per file.
Running files from your graphical file manager
If you prefer not to use the terminal, you can run executable files by double-clicking them in your file manager (like Nautilus, Dolphin, or Thunar, depending on your Linux desktop). First, make sure the file is marked as executable using chmod +x as described above. Then open your file manager, find the file, and double-click it.
Your system may ask you whether you want to run the file or edit it. Choose "Run" or "Execute" to start the program. Some systems will run the file when ready; others may open it in a text editor by default. If that happens, close the editor and use the terminal method instead, which is more reliable.
Understanding what happens when a program runs
When you run an executable file, the program starts and may print messages to your terminal. Some programs finish quickly and return you to the command prompt. Others stay open and keep running until you close them or press Ctrl+C to stop them. If a program seems to hang or freeze, pressing Ctrl+C will usually stop it and return control to you.
Some programs run in the background, which means they start but do not print anything to your terminal and do not wait for you to close them. If you want to run a program in the background intentionally, type the command followed by an ampersand (&), like ./myprogram &. This lets you keep using the terminal while the program runs separately.
Troubleshooting common problems
If you type a command and get "command not found", you either typed the filename wrong or you are not in the right folder. Double-check the spelling and use pwd to confirm your location. If you get "Permission denied", the file is not executable — use chmod +x to fix it.
If a program starts but when ready closes or shows an error, the program itself may have a problem, or it may need additional files or libraries to run. Check the program's documentation or look for a README file in the same folder. Some programs also need to be run from a specific folder or with specific options — the documentation will tell you what those are.
Frequently Asked Questions
What is the difference between ./ and just typing the filename?
The ./ tells Linux to look for the file in your current folder. Without it, Linux searches your PATH — a list of system program folders. Most of your personal files are not in those folders, so typing just the filename will not work. The ./ is the way to say "run this file from where I am right now".
Do I need to use chmod every time I run a file?
No. You only run chmod +x once per file. After that, the file stays executable. The permission is stored with the file itself, so the next time you run it, you can start it when ready without running chmod again.
Can I run a file without opening the terminal?
Yes, if the file is marked as executable, you can double-click it in your file manager. However, the terminal method is more reliable because you can see error messages if something goes wrong. If double-clicking does not work, the terminal is your backup.
What does the ampersand (&) do at the end of a command?
The ampersand runs the program in the background, which means it starts but does not hold up your terminal. You can keep typing commands while the program runs. Without the ampersand, the terminal waits for the program to finish before letting you type again.
Why do some files have .sh or .run at the end and others do not?
The file extension does not matter to Linux — a file is executable or it is not, based on its permissions. Extensions like .sh and .run are just hints to humans about what kind of file it is. A file with no extension can be just as executable as one with .sh at the end.