Linux Commands Ubuntu

How do I run a file in a terminal using Linux/Ubuntu?

How do I run a file in terminal using Linux Ubuntu

The file system in Ubuntu is crucial to know as it is used to store, manage, and manipulate data. The file structure and system change according to the type of data. Understanding the file system is essential for effective system administration. There are two particular methods to run a file in Ubuntu. One method is the use of File Manager or GUI (Graphical User Interface) and the other method is the Terminal or CLI (Command Line Interface).

In this article, we will see the stepwise procedure for running a file in Ubuntu using the Terminal.

How Do I Run a File in a Terminal Using Linux/Ubuntu?

The Ubuntu Terminal is a preferred way of running the files as it provides “Flexibility”, “Automation” and “Debugging”. Follow the steps below to run Files in Ubuntu using the terminal:

Step 1: Open Terminal

To open the terminal in Ubuntu, navigate to the “Show Applications” icon and click on it or press the Windows Button on your Keyboard to open the “Show Applications” menu directly:

Here the applications will be displayed. On the Top of your screen, you can see the “Search” box. Click on it and type the application you want to filter/open:

In your case, you will type “Terminal”:

The Terminal Application appears and you can open it either by pressing “Enter” or clicking on it:

To open the Terminal using the Shortcut Key, press the default “ctrl+alt+T” keys to open it directly

Pressing these keys wherever will open the terminal:

Step 2: Navigate to the Directory

To navigate to a directory, use the “cd” command with the directory name:

cd <Directory>

In our case, if we want to go to the Documents Directory we will use the command:

cd Documents

The Documents directory will be accessed and can be seen in the terminal

To get out of the directory either use the “cd” command as it is or with two dots:



cd ..

Step 3: Run the File

To run a file in Ubuntu, a better approach is to first list all the files in the directory and then run it. To list the files in the Documents directory, we will use the command:


The filenames in that directory will be displayed in the terminal

As in your system, you can have different types of files. To run each type of file, you will use a specific command. The different types of files in Ubuntu are “Regular files”, “odt files”, “Script files”, “Configuration files”, “Archive files”, “Executable files” and many more.

Running Regular Files

The Regular files consist of:

  • Text Files (.txt)
  • Audio Files (.mp3)
  • Video Files (.mp4)
  • Images (.jpg/.jpeg)

Running a Text File

To run a text file in Ubuntu, use the “nano” command along with the file name. In the following example, we are executing the nano command to run the “abc.txt” file:

sudo nano abc.txt

This will open the nano text editor for the “abc.txt” file:

Running a Video File

To run a video file, use the “xdg-open” command:

xdg-open <filename>

In our case, we have a Video file “RickRolled.mp4” in our Documents Directory:

To run this video file, use the command:

xdg-open RickRolled.mp4

On successful execution of the stated command, the selected video file will start playing:

Running an Audio File

To run an audio file, you will use the “ffplay” command followed by the file name:

ffplay <<strong>filename</strong>>

In our case, we have the file “RickTest.mp3”:

To run this audio file, use the command:

ffplay RickTest.mp3

A pop-up window will appear and the audio will play automatically:

Opening/Running an Image File

To open or run an Image (.jpg) file in Ubuntu, use the “eog” command along with the file name:

eog <<strong>filename</strong>>

In our case, we have an image “Linux.jpeg” in our directory:

To open the image, use the command

eog Linux.jpeg

This will open the image using the default Ubuntu GNOME:

Running ODT Files

We can use the terminal to run ODT Files as well. To run the ODT File in Linux, use the “lowriter” command:

lowriter <filename>

In our case, we have a file “Word.odt” in our directory

To run this file, use the “lowriter” command followed by the file name:

lowriter Word.odt

This will open our file. Ignore the warning message.

Running Script Files

To run a script File in Ubuntu, make it executable first using the command below and then execute the shell. In our case, we have a script file “” in our directory:

To run this script file, make the script executable using the following “chmod” command:

chmod +x

Once the file is executable, execute now using the command:


This will run the script file and show the output in the terminal:

Running Configuration Files

To run Configuration Files in the Ubuntu Terminal, use the “nano” command along with the path and name of the configuration file:

nano /etc/<path>/<filename>.conf

In our case, to open the “debconf.conf” configuration file, use the following “nano” command:

sudo nano /etc/debconf.conf

This will run the configuration file and you can make changes to it:

There you go! you have successfully learned how to run different types of files in Ubuntu 22.04 using a terminal.


Files can be executed and opened easily using the Ubuntu Terminal. Opening files in the Terminal is a preferred way if you want more flexibility and accessibility over the GUI. This article explained how we can run Regular Files, OTD Files, Configuration Files, and Script Files using different commands in the Terminal.


Similar Posts