- How to Run a Program from the Command Line on Linux
- Running a Program From the Terminal
- Running a Program Outside the $PATH Variable
- Adding a Directory to your $PATH Variable
- Installing and Uninstalling a Program in the Terminal
- Expert Q&A
- Tips
- You Might Also Like
- How to Execute .RUN Files in Linux
- Expert Q&A
- Tips
- You Might Also Like
- How to Execute .bin and .run Files in Ubuntu
- Executing .bin and .run files
- Search
- About This Site
- Latest Tutorials
How to Run a Program from the Command Line on Linux
This article was co-authored by wikiHow staff writer, Travis Boylls. Travis Boylls is a Technology Writer and Editor for wikiHow. Travis has experience writing technology-related articles, providing software customer service, and in graphic design. He specializes in Windows, macOS, Android, iOS, and Linux platforms. He studied graphic design at Pikes Peak Community College.
The wikiHow Tech Team also followed the article’s instructions and verified that they work.
This article has been viewed 277,537 times.
Most Linux distributions have a graphical user interface that allows you to open programs by just clicking on the program’s icon in the Apps menu. However, there are situations where you may want to run a program from the Terminal. The Terminal is a powerful tool that allows you to run programs and manage your Linux system using keyboard commands. This wikiHow teaches you how to run a program from the Terminal in Linux.
Running a Program From the Terminal
Press Ctrl + Alt + T to open the Terminal. You can open the Terminal using the keyboard shortcut on most Linux distributions. The keyboard shortcut is Ctrl + Alt + T. You can also click the Terminal icon in your Apps menu. It generally has an icon that resembles a black screen with a white text cursor.
- For example, if you want to run Firefox from the Terminal, you would simply type firefox and press Enter.
- Type -h or —help after the program name to display the help menu for that program. Many programs have additional command modifiers you can use to launch the program in a specific way. For example, you can launch a website in a web browser by typing the web browser name followed by the web address and press Enter to launch that website in the web browser (i.e. firefox www.wikihow.com .
- If you receive a message that says you don’t have permission to run a program or access is denied, type sudo before the program name and press Enter. The «sudo» command allows regular users to run Terminal commands with administrative privileges or root access.
- If you want to run a C or C++ program from the Terminal, you will first need to complie the program before you can launch it from the Terminal.
Running a Program Outside the $PATH Variable
Press Ctrl + Alt + T to open the Terminal. You can open the Terminal using the keyboard shortcut on most Linux distributions. The keyboard shortcut is Ctrl + Alt + T. You can also click the Terminal icon in your Apps menu. It generally has an icon that resembles a black screen with a white text cursor.
Type cd followed by a space and the location the program file is saved to. If the program launch file is saved to a location that is not in your $PATH variable, then you will need to navigate to that location inside the Terminal. You can do so using the «cd» command. For example, if you have folder for Python programs saved in your «Documents» folder, you can navigate to it in the Terminal by typing cd ~/Documents/Python or something similar, and then press Enter.
Type chmod a+x [filename] and press ↵ Enter . Replace «filename» with the actual launch file of the program. The «chmod a+x» command tells Linux the file is an executable file. [1] X Research source
Type «./» followed by the launch filename and press ↵ Enter . This launches the program. For example, if you have a Python file called «Helloworld.py», you would type ./helloworld.py to launch the file. [2] X Research source
Adding a Directory to your $PATH Variable
Press Ctrl + Alt + T to open the Terminal. If you cannot run a program by simply typing the program’s name, you may need to add the directory that the program is installed in to your $PATH variable. You can do this from the Terminal as well. Use the keyboard shortcut to open the Terminal if you haven’t already done so.
- For example, if you have a program installed in the «bin» directory of your «Home» folder, you would type export PATH=$PATH:$Home/bin and press Enter. This will temporarily add the «$Home/bin» directory to your $PATH variable.
- You can see which directories are currently added to your $PATH variable by typing the command echo $PATH and pressing Enter.
Type nano ~/.bashrc and press ↵ Enter . This opens the «.bashrc» file in a text editor that is based in the Terminal. You can use this file to permanently add the directory to your $PATH variable.
Add the «export PATH» command to the file. To do so, scroll down to the bottom of the file using the mouse wheel and type export PATH=$PATH:[path/to/program] at the bottom. Replace «[path/to/program]» with the actual directory tree the program is installed in. [3] X Research source
Press Y and press ↵ Enter . This confirms that you want to save and exit the text editor. You will be returned to the standard command prompt in the Terminal.
Type source ~/.bashrc and press ↵ Enter . This loads the updated $PATH variable into your current session. [4] X Research source
Type the name of the program and press ↵ Enter . With the program’s directory now added to your $PATH variable, you should be able to launch the program by simply typing the program name and pressing Enter.
Installing and Uninstalling a Program in the Terminal
Press Ctrl + Alt + T to open the Terminal. In addition to launching programs from within the Terminal, you can also install and uninstall programs from within the Terminal. Use the keyboard shortcut to open the Terminal if you haven’t already done so.
Type sudo apt install [app_name] and press ↵ Enter (Debian). Replace «[app_name]» with the actual name of the program you want to install. This command works in Debian-based Linux distributions, such as Ubuntu, and Mint.
Type sudo apt remove [app_name] and press ↵ Enter (Debian). Replace «[app_name]» with the name of the app you want to uninstall. This command works in Debian-based Linux distributions, such as Ubuntu, and Mint.
Type sudo dnf install [app_name] and press ↵ Enter (Red Hat). Replace «[app_name]» with the actual name of the program you want to install. This command works for Red Hat Linux distributions such as RHEL, Fedora, and CentOS.
Type sudo dnf remove [app_name] and press ↵ Enter (Red Hat). Replace «[app_name]» with the name of the app you want to uninstall. This command works for Red Hat Linux distributions such as RHEL, Fedora, and CentOS. [5] X Research source
Type the name of the program and press ↵ Enter . Once the program is installed, you can launch the program by simply typing the program’s name and pressing Enter in the Terminal.
Expert Q&A
Tips
You Might Also Like
How to Change 4-Digit User Codes on Schlage Locks
How to Delay a Batch File: Timeout, Pause, Ping, Choice & Sleep
How to Factory Reset a Schlage Lock & Restore the Default Programming Code
Learn to Write Pseudocode: What It Is and Why You Need It
How to Start Coding: The Beginner’s Guide to Programming
3 Ways to Download GitHub Directories and Repositories
How to Execute .RUN Files in Linux
wikiHow is a “wiki,” similar to Wikipedia, which means that many of our articles are co-written by multiple authors. To create this article, volunteer authors worked to edit and improve it over time.
This article has been viewed 54,289 times.
.RUN files usually contain program data and installation instructions for Linux programs. This wikiHow teaches you how to execute .RUN files in Linux using the Ubuntu terminal. Since RUN files install software, make sure it’s legitimate and won’t harm your computer before executing it. RUN files from suspicious links can contain malware and damage your computer.
Press Ctrl + Alt + T to open a Terminal window and navigate to the folder where your .RUN file is. You can also search for Terminal in the «dash» bar on the left side of your screen by clicking the «All Applications» icon.
- If you get a «Permission denied» error during this process, add » sudo » to the beginning of the code so it will run with the appropriate permissions. [1] X Research source
Expert Q&A
Tips
You Might Also Like
Can Linux Run .exe Files? How to Run Windows Software on Linux
How to Open Linux Firewall Ports: Ubuntu, Debian, & More
How to Run an INSTALL.sh Script on Linux in 4 Easy Steps
Use Ping in Linux: Tutorial, Examples, & Interpreting Results
How to Delete Read-Only Files in Linux
How to Install Linux on Your Computer
How to Install Software on Linux: Packages, Compiling, & More
How to Execute .bin and .run Files in Ubuntu
Before we explain how to run .bin and .run files on your Ubuntu system, let’s first define what exactly these file extensions are:
Bin file: A binary or BIN file in Ubuntu refers to installation packages, which are mostly self-extracting executable files used to install software on your system. You can install most software packages through the Ubuntu Software Manager, such as .deb packages and .tar.xz packages. However, there is software that is not available in these formats. This mainly includes newer software and newer versions of software, usually beta versions, that are not otherwise available. The bin packages are simply run from the Ubuntu command line, the terminal.
Run File: These are also executable files typically used to install Linux programs. Run Files contain program data and instructions for installation; they are often used for distributing device drivers and software applications. Run packages are easily executed from the Ubuntu command line, the terminal.
In this article, we will explain how to run/execute the files with .run and .bin extensions on Ubuntu Linux.
We have run the commands and procedures mentioned in this article on an Ubuntu 22.04 LTS system. We will use the Ubuntu command line, the terminal, to explain how to run bin and run files. You can open the terminal application either by searching in the system application launcher or by pressing Ctrl+Alt+T.
Note: Make sure that your .run and .bin files are from a reliable source, because running an unsafe file can damage your system and even compromise your system security.
Executing .bin and .run files
The process of running both the run and BIN files is pretty simple and straightforward in Ubuntu.
We are assuming that you have already downloaded your bin/run file in a known location on your Ubuntu.
Open the Terminal application and move to the location where you have saved the executable file.
For example, I would use the following command to move to my Downloads folder:
Now use the following command to make your .bin/.run file executable:
In this example, I will be making a sample .run file named samplefile.run executable.
If your .run/.bin file does not exist in the current location, you can specify the exact file path/location in the above commands.
My file is now marked as executable. The system indicates it by a change in color of the filename when listed through the ls command:
Once your .bin/.run file has become executable, you can use the following command to execute/run it:
You can specify the path of the executable file in the above command if it does not exist in the current folder you are in.
My sample file is pretty much an empty file. In the case of a proper installation package, the installation process will begin after you execute the file.
This is the power of the Ubuntu command line. You can install rare software packages available in the .run and .bin formats easily on your system.
Search
About This Site
Vitux.com aims to become a Linux compendium with lots of unique and up to date tutorials.