Clear, practical technology insights BSOD Code Lookup · Windows Error Code Lookup · Wi-Fi Troubleshooting · PC Troubleshooting Checklist

How to Launch Programs from Command Line on Linux

Learn about Run Programs from Command Line on Linux, how it works, key uses, practical steps, common issues, and answers to common questions.

Table of Contents

Launch the Program from Terminal

Launch the Program from Terminal - Run Programs from Command Line on Linux

This practical guide explains how to launch programs from command line on linux with clear steps and useful context. It also covers common requirements, potential problems, and the details that can help you get better results.

Launch the Program from Terminal - Run Programs from Command Line on Linux

Type the program name and then press ? Enter. Unlike the Windows command line (CMD), you don't need to enter the full path or change the directory for most programs on Linux. As long as the program is in the user's "$PATH" environment variable, Linux will automatically search for and launch it.

For example, if you want to launch Firefox from the Terminal, you need to type firefox and press Enter.

Type -h or --help after the program name to display the program's help menu. Many programs have additional command modifiers that are used to run the program in a particular way. For example, you can launch a web browser by typing the web browser's name, followed by the web address, and then pressing Enter to access the website using that web browser (e.g. firefox www.wikihow.com).

If the command line returns a message that you do not have permission to run the program or that access is denied, type sudo in front of the program name and then press Enter. The "sudo" command will allow regular users to execute Terminal commands as administrator or with super-access (aka root privileges).

If you want to launch a C or C++ programming language program from the Terminal, you need to compile the program first.

Launch a Program Outside of the $path. Variable

Launch a Program Outside of the $path. Variable - Run Programs from Command Line on Linux

Press Ctrl+Alt+T to open Terminal. You can open Terminal with the keyboard shortcut Ctrl + Alt + T on most Linux distributions. Alternatively, you can also click the Terminal icon in the Apps menu. Programs often have a black screen icon with a white text cursor.

Launch a Program Outside of the $path. Variable - Run Programs from Command Line on Linux

Enter the command cd, followed by a space and the location where the program file is saved. If the program launches the file stored in a location that is not in the $PATH variable, you need to navigate to that directory in Terminal using the "cd" command. For example, if the Python program's directory is in the "Documents" folder, you can go there on Terminal by typing cd ~/Documents/Python or similar, and then pressing Enter.

Launch a Program Outside of the $path. Variable - Run Programs from Command Line on Linux

Type chmod a+x [filename] and press ? Enter. Remember to replace "filename" with the actual launch file name of the program. The command "chmod a+x" will tell Linux this is an executable file.

Launch a Program Outside of the $path. Variable - Run Programs from Command Line on Linux

Type "./" with the executable file name and then press ? Enter. The program will be launched. For example, if the Python program executable file is named "Helloworld.py", you need to type./helloworld.py to launch the file.

Add the Directory to the $path. Variable

Add the Directory to the $path. Variable - Run Programs from Command Line on Linux

Press Ctrl+Alt+T to open Terminal. If the program does not run after entering the name, you may need to add the program's directory to the $PATH variable. This can also be done from Terminal. First, proceed to press the key combination to open Terminal if the program is not already open.

Add the Directory to the $path. Variable - Run Programs from Command Line on Linux

Enter the command to export the program directory into the $PATH variable. To proceed, you need to type export PATH=$PATH:[path/to/program] and then press Enter. Remember to replace "[path/to/program]" with the actual directory tree where the program is installed. This command is only valid until the end of the current session.

For example, if the program you want to launch is installed in the "bin" directory of the "Home" directory, type export PATH=$PATH:$Home/bin and press Enter. The directory "$Home/bin" will be temporarily added to the $PATH variable.

You can view the directories under the $PATH variable by typing echo $PATH and pressing Enter.

Add the Directory to the $path. Variable - Run Programs from Command Line on Linux

Type the command nano ~/.bashrc and then press ? Enter. The file ".bashrc" will be opened in a Terminal-based text editor. You can use this file to add directories to the $PATH variable permanently.

Add the Directory to the $path. Variable - Run Programs from Command Line on Linux

Add the "export PATH" command to the file. To proceed, scroll to the bottom of the file with your mouse wheel and enter export PATH=$PATH:[path/to/program] there. Remember to replace "[path/to/program]" with the actual directory tree in which the program is installed.

Add the Directory to the $path. Variable - Run Programs from Command Line on Linux

Press Ctrl+X to exit the text editor. You will be asked if you want to save the file.

Add the Directory to the $path. Variable - Run Programs from Command Line on Linux

Press Y and press ? Enter. This step is to confirm that you want to save the file and exit the text editor. You will return to the standard command prompt on Terminal.

Add the Directory to the $path. Variable - Run Programs from Command Line on Linux

Type source ~/.bashrc and press ? Enter. This command will load the newly updated $PATH variable into the current session.

Add the Directory to the $path. Variable - Run Programs from Command Line on Linux

Type the name of the program to launch and press ? Enter. Now that you have added the program's directory to the $PATH variable, you should be able to launch the program with the simple act of typing the program name and then pressing Enter.

Install and Uninstall Programs on Terminal

Install and Uninstall Programs on Terminal - Run Programs from Command Line on Linux

Press Ctrl+Alt+T to open Terminal. Besides launching programs from the Terminal, you can also install and uninstall programs through command prompt operation. First, open Terminal by pressing a key combination (if the program isn't already open).

Install and Uninstall Programs on Terminal - Run Programs from Command Line on Linux

Type sudo apt install [app_name] and press ? Enter (Debian). Don't forget to replace "[app_name]" with the actual name of the program you want to install. This command works for Debian-based Linux distributions, such as Ubuntu and Mint.

Install and Uninstall Programs on Terminal - Run Programs from Command Line on Linux

Type the command sudo apt remove [app_name] and press ? Enter (Debian). Remember to replace "[app_name]" with the name of the app you want to uninstall. This command works for Debian-based Linux distributions, such as Ubuntu and Mint.

Install and Uninstall Programs on Terminal - Run Programs from Command Line on Linux

Type sudo dnf install [app_name] and then press ? Enter (Red Hat). Don't forget to replace "[app_name]" bawfg with the actual name of the program you want to install. This command works for Red Hat-based Linux distributions, such as RHEL, Fedora, and CentOS.

Install and Uninstall Programs on Terminal - Run Programs from Command Line on Linux

Type sudo dnf remove [app_name] and press ? Enter (Red Hat). Remember to replace "[app_name]" with the name of the app you want to uninstall. This command works for Red Hat-based Linux distributions, such as RHEL, Fedora, and CentOS.

Install and Uninstall Programs on Terminal - Run Programs from Command Line on Linux

Type the program name and press ? Enter. After the program is installed, you can proceed to launch it on Terminal with just a simple operation, which is to enter the program name and then press Enter.

Conclusion

Understanding Run Programs from Command Line on Linux makes it easier to compare options, avoid common mistakes, and apply the information in this guide more effectively. Review the relevant requirements before making changes or choosing a solution.

FAQ

How do you launch programs from command line on linux?

Follow the steps in this guide in order, confirm the required settings or tools, and verify the result before making additional changes.

Is it safe to launch programs from command line on linux?

It is generally safe when you follow the recommended instructions, use trusted tools, and avoid changing settings you do not understand.

What should you do if the process does not work?

Recheck the requirements, restart the device or application when appropriate, and review each step for missed settings or compatibility issues.

Discussion

Reader Comments 0

Sign in with email or Google to join the discussion.