Running an executable file in Linux means telling the system to start a program you have stored on your computer

The most direct way is to type the full path to the file followed by Enter. If the file is in your current folder, you type ./filename (the dot-slash tells Linux to look in the current directory). If the file is somewhere else, you type the complete path, like /home/username/Downloads/myprogram. Before you can run a file, it must have execute permission — a setting that marks it as runnable rather than just readable.

Most executable files you download or create will not have execute permission by default. You have to add it first using the chmod command, which changes file permissions. After that single step, the file will run when you type its name or path.

Key Takeaways

  • Executable files need execute permission before they will run; add it with chmod +x filename in the directory where the file sits.
  • Run a file in your current folder by typing ./filename, or run a file elsewhere by typing its full path like /home/username/Downloads/program.
  • The dot-slash (./) is required when running a file in your current directory; without it, Linux searches your system PATH instead of the current folder.
  • You can check if a file has execute permission by typing ls -l filename and looking for an x in the permission string.

Check and add execute permission to your file

Before running any executable, verify it has the permission to run. Open your terminal, navigate to the folder containing the file, and type ls -l filename (replace "filename" with the actual name). The output shows a string of letters and dashes at the start — if you see an x in that string, the file already has execute permission and you can skip to running it.

If there is no x, add execute permission by typing chmod +x filename and pressing Enter. This command adds the execute bit to the file. You only need to do this once per file. After that, the file will run whenever you call it.

A common mistake is typing the command in the wrong directory. If you get a "No such file or directory" error, use pwd to see where you are, then cd to move to the correct folder. For example, cd Downloads moves you into the Downloads folder in your home directory.

Run the file from your current directory

Once the file has execute permission, run it by typing ./filename and pressing Enter. The dot-slash is essential — it tells Linux to look for the file in the current directory rather than searching your system PATH (the list of folders Linux checks automatically for programs). Without the dot-slash, you will get a "command not found" error even though the file is right there.

For example, if your file is called myscript, you type ./myscript. If it is called setup.sh, you type ./setup.sh. The file extension does not matter to Linux — it runs the file based on its permissions, not its name.

Some programs print output to the terminal as they run. Others run silently and return you to the prompt when finished. If nothing seems to happen, the program may have completed successfully. To confirm, type echo $? — if it prints 0, the last command succeeded.

Run a file from a different directory

If the executable is not in your current folder, type the full path to it instead of using dot-slash. For example, /home/username/Downloads/myprogram or ~/Desktop/installer (the tilde ~ means your home directory). This tells Linux exactly where to find the file.

You do not need to navigate to the file's folder first — you can run it from anywhere. This is useful when you want to run a program that lives in a specific location but you are working in a different directory. The file still needs execute permission, so if you get a "Permission denied" error, go to its folder and run chmod +x filename first.

If you use the same program often, you can add its folder to your system PATH so you can type just the filename without the path. This is more advanced and requires editing your shell configuration file, but it saves typing for frequently-used programs.

Understand what happens when a file runs

When you run an executable, Linux launches a new process — a separate instance of the program running in memory. The program may read files, write output, or interact with your system depending on what it is designed to do. Some programs return control to the terminal immediately; others keep running until you stop them or they finish on their own.

If a program is taking too long or appears stuck, you can stop it by pressing Ctrl+C. This sends an interrupt signal that tells the program to quit. Most programs respond immediately, though some may take a moment to shut down cleanly.

Programs can also accept arguments — extra information you type after the filename. For example, ./myprogram --help might show you options the program supports, or ./converter input.txt output.txt might tell the program which files to work with. Check the program's documentation to see what arguments it accepts.

Troubleshoot common errors when running files

Permission denied: The file does not have execute permission. Run chmod +x filename in the file's directory, then try again.

Command not found: You typed the filename without dot-slash, or the path is wrong. Use ./filename if the file is in your current directory, or type the full path like /home/username/Downloads/filename.

No such file or directory: The file does not exist at the path you typed, or you are in the wrong directory. Use pwd to see where you are, and ls to list files in the current folder. Then navigate to the correct location or type the correct path.

Segmentation fault or other runtime errors: The program ran but crashed. This usually means the program itself has a bug, or you passed it incorrect arguments. Check the program's documentation or try running it with --help to see what it expects.

Run scripts written in interpreted languages

Some executable files are scripts written in languages like Python, Bash, or Perl rather than compiled programs. These files still need execute permission, but they also need a special first line called a shebang that tells Linux which interpreter to use.

A shebang looks like #!/usr/bin/python3 or #!/bin/bash and must be the very first line of the file. It starts with a hash and exclamation mark, followed by the path to the interpreter. After you add execute permission with chmod +x, you can run the script by typing ./scriptname just like any other executable.

If a script does not have a shebang, you can still run it by calling the interpreter directly: python3 myscript.py or bash myscript.sh. This method works even if the file does not have execute permission, because you are running the interpreter itself, not the script file.

Frequently Asked Questions

Do I need to be in the same folder as the executable to run it?

No. You can run a file from any directory by typing its full path, like /home/username/Downloads/myprogram. However, if the file is in your current directory, you must use dot-slash (./filename) rather than just the filename, or Linux will search your PATH instead.

What is the difference between chmod +x and chmod 755?

chmod +x adds execute permission for everyone (user, group, and others). chmod 755 sets specific permissions: the owner can read, write, and execute; the group and others can only read and execute. For most cases, chmod +x is sufficient. Use 755 if you want to restrict write access.

Can I run an executable that I do not own?

Yes, as long as it has execute permission for your user. You can run any executable in any folder you can access. The owner of the file does not have to be you. If you get a "Permission denied" error, the file may not have execute permission for your user account.

What does the dot-slash actually do?

The dot represents your current directory, and the slash separates it from the filename. Together, ./filename tells Linux to look for the file in the current directory instead of searching your system PATH. Without it, Linux assumes you are calling a system command and searches standard program folders.

How do I know if a file is actually executable or just has the permission set?

You can only know by trying to run it. Having execute permission means Linux will attempt to run the file, but the file itself might not be a valid executable — it could be corrupted or in a format your system does not support. If it fails to run, check the file type with file filename to see what kind of file it actually is.