This guide will show you how to run files in Linux. You can execute most files through a graphical file manager, which is typically pre-installed on most Linux distributions. Alternatively, the Terminal provides a powerful command-line interface, especially useful for running script files like .sh, .run, and .bin.

Before you start: Ensure you have the necessary permissions to execute files, or know your user password for sudo commands.

How to run a file in Linux

Follow these detailed steps to execute files on your Linux system, using either a graphical file manager or the command line.

Using a file manager

  • Open a file manager application. Most Linux distributions include a default file manager such as Nautilus, Thunar, Dolphin, Krusader, Konqueror, or PCManFM. You can typically find its icon resembling a file cabinet or a folder labeled “Home” on your desktop, dock, or Activities menu.
    • If you can’t find it:Press the Super (Windows) key and type “Files” into the search bar.
    • To install a different file manager:Open the Terminal.
      • If Debian/Ubuntu:Typesudo apt install <app name> and press Enter.
      • If Fedora:Typesudo dnf install <app name> and press Enter. (Replace <app name> with the desired application name.)
  • Navigate to the folder where your file is located by double-clicking folders in the large browsing panel.
  • Right-click the file you want to run to display a drop-down menu. You can also double-click the file to run it with its default associated application.
  • ClickOpen With or Open With Other Application from the menu.
  • Double-click the application you want to use to run the file. If your desired application is not immediately visible, clickView All Applications or Other to see a categorized list of all installed apps.

Using the Terminal

  • PressCtrl+Alt+T to open the Terminal. Alternatively, click the Terminal icon (often a black screen with a white text cursor) in your Apps menu.
  • Change the directory to the folder containing the file. Typecd followed by the directory path (e.g., cd /Documents) and press Enter.
  • Typesudo chmod +x <filename> and press Enter. (Replace <filename> with the exact name of your file, ensuring no spaces). This command grants execute permissions to the file. If prompted, enter your Linux computer’s password and press Enter.
  • Type the appropriate command to run the file based on its type and press Enter:
    • To run executable scripts (.sh, .run, .bin):Typesudo ./<filename>
    • To open a file with its default application:Typexdg-open <filename>
    • To display an image file (requires ImageMagick):Typedisplay <filename>
    • To display a text file directly in the Terminal:Typecat <filename>
    • To display a text file one page at a time:Typeless <filename>
    • To display a text file with numbered lines:Typenl <filename>
Pro tip: When working in the Terminal, you can use the Tab key for auto-completion of file and directory names, which saves time and prevents typos.

What to do next?

Mastering file execution is a fundamental skill in Linux. Once you’re comfortable with these methods, consider exploring other powerful aspects of the Linux command line. Learning more commands can significantly enhance your productivity and control over your system.

You might also want to delve into shell scripting, which allows you to automate repetitive tasks and create custom commands. Many online resources and communities are available to help you continue your journey in Linux, providing a pathway to becoming a more proficient user.