• About
  • Contact
  • Cookie
  • Disclaimer
  • Privacy Policy
  • Change the purpose of use

Tnhelearning.edu.vn - Various useful general information portal

  • Photo
  • Bio
  • How To
  • Tech

How to Launch Programs from Command Line on Linux

February 15, 2024 by admin Category: How To

You are viewing the article How to Launch Programs from Command Line on Linux  at Tnhelearning.edu.vn you can quickly access the necessary information in the table of contents of the article below.

X

This article is co-authored by a team of editors and trained researchers who confirm the accuracy and completeness of the article.

The wikiHow Content Management team carefully monitors the work of editors to ensure that every article is up to a high standard of quality.

This article has been viewed 4,760 times.

Most Linux distributions have a graphical user interface that allows us to open programs just by clicking on the program icon in the Apps menu. However, sometimes you may want to launch programs from Terminal. Terminal is a powerful tool that allows users to launch programs and manage Linux systems through keyboard commands. This wikiHow teaches you how to launch programs from Terminal on Linux.

Table of Contents

  • Steps
    • Launch the program from Terminal
    • Launch a program outside the $PATH . variable
    • Add the directory to the $PATH . variable
    • Install and uninstall programs on Terminal

Steps

Launch the program from Terminal

Image titled Run a Program from the Command Line on Linux Step 1

Image titled Run a Program from the Command Line on Linux Step 1

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/a/a2/Run-a-Program-from-the-Command-Line-on-Linux-Step-1.jpg/v4- 728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-1.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/a/a2/ Run-a-Program-from-the-Command-Line-on-Linux-Step-1.jpg/v4-728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-1. jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser-output”></div>”}
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. The program usually has a black screen icon with a white text cursor.
Image titled Run a Program from the Command Line on Linux Step 2

Image titled Run a Program from the Command Line on Linux Step 2

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/f/f1/Run-a-Program-from-the-Command-Line-on-Linux-Step-2.jpg/v4- 728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-2.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/f/f1/ Run-a-Program-from-the-Command-Line-on-Linux-Step-2.jpg/v4-728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-2. jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser-output”></div>”}
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 directories 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.
READ More:   How to Create New Files on Windows

Launch a program outside the $PATH . variable

Image titled Run a Program from the Command Line on Linux Step 3

Image titled Run a Program from the Command Line on Linux Step 3

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/8/88/Run-a-Program-from-the-Command-Line-on-Linux-Step-3.jpg/v4- 728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-3.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/8/88/ Run-a-Program-from-the-Command-Line-on-Linux-Step-3.jpg/v4-728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-3. jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser-output”></div>”}
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. The program usually has a black screen icon with a white text cursor.
Image titled Run a Program from the Command Line on Linux Step 4

Image titled Run a Program from the Command Line on Linux Step 4

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/9/9e/Run-a-Program-from-the-Command-Line-on-Linux-Step-4.jpg/v4- 728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-4.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/9/9e/ Run-a-Program-from-the-Command-Line-on-Linux-Step-4.jpg/v4-728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-4. jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser-output”></div>”}
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 .
Image titled Run a Program from the Command Line on Linux Step 5

Image titled Run a Program from the Command Line on Linux Step 5

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/4/45/Run-a-Program-from-the-Command-Line-on-Linux-Step-5.jpg/v4- 728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-5.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/4/45/ Run-a-Program-from-the-Command-Line-on-Linux-Step-5.jpg/v4-728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-5. jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser-output”></div>”}
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 that this is an executable file. [1] X Research Source
Image titled Run a Program from the Command Line on Linux Step 6

Image titled Run a Program from the Command Line on Linux Step 6

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/a/a2/Run-a-Program-from-the-Command-Line-on-Linux-Step-6.jpg/v4- 728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-6.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/a/a2/ Run-a-Program-from-the-Command-Line-on-Linux-Step-6.jpg/v4-728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-6. jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser-output”></div>”}
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. [2] X Research Source

Add the directory to the $PATH . variable

Image titled Run a Program from the Command Line on Linux Step 7

Image titled Run a Program from the Command Line on Linux Step 7

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/3/30/Run-a-Program-from-the-Command-Line-on-Linux-Step-7.jpg/v4- 728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-7.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/3/30/ Run-a-Program-from-the-Command-Line-on-Linux-Step-7.jpg/v4-728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-7. jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser-output”></div>”}
Press Ctrl + Alt + T to open Terminal. If the program doesn’t 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.
Image titled Run a Program from the Command Line on Linux Step 8

Image titled Run a Program from the Command Line on Linux Step 8

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/5/51/Run-a-Program-from-the-Command-Line-on-Linux-Step-8.jpg/v4- 728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-8.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/5/51/ Run-a-Program-from-the-Command-Line-on-Linux-Step-8.jpg/v4-728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-8. jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser-output”></div>”}
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 see the directories under the $PATH variable by typing echo $PATH and pressing Enter .
READ More:   How to Lose Body Fat
Image titled Run a Program from the Command Line on Linux Step 9

Image titled Run a Program from the Command Line on Linux Step 9

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/3/3b/Run-a-Program-from-the-Command-Line-on-Linux-Step-9.jpg/v4- 728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-9.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/3/3b/ Run-a-Program-from-the-Command-Line-on-Linux-Step-9.jpg/v4-728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-9. jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser-output”></div>”}
Type the command nano ~/.bashrc and then press ↵ Enter . The “.bashrc” file will be opened in a Terminal-based text editor. You can use this file to add directories to the $PATH variable permanently.
Image titled Run a Program from the Command Line on Linux Step 10

Image titled Run a Program from the Command Line on Linux Step 10

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/1/16/Run-a-Program-from-the-Command-Line-on-Linux-Step-10.jpg/v4- 728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-10.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/1/16/ Run-a-Program-from-the-Command-Line-on-Linux-Step-10.jpg/v4-728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-10. jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser-output”></div>”}
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. [3] X Research Sources
Image titled Run a Program from the Command Line on Linux Step 11

Image titled Run a Program from the Command Line on Linux Step 11

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/9/9b/Run-a-Program-from-the-Command-Line-on-Linux-Step-11.jpg/v4- 728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-11.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/9/9b/ Run-a-Program-from-the-Command-Line-on-Linux-Step-11.jpg/v4-728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-11. jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser-output”></div>”}
Press Ctrl + X to exit the text editor. You will be asked if you want to save the file.
Image titled Run a Program from the Command Line on Linux Step 12

Image titled Run a Program from the Command Line on Linux Step 12

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/b/b9/Run-a-Program-from-the-Command-Line-on-Linux-Step-12.jpg/v4- 728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-12.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/b/b9/ Run-a-Program-from-the-Command-Line-on-Linux-Step-12.jpg/v4-728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-12. jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser-output”></div>”}
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.
Image titled Run a Program from the Command Line on Linux Step 13

Image titled Run a Program from the Command Line on Linux Step 13

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/2/25/Run-a-Program-from-the-Command-Line-on-Linux-Step-13.jpg/v4- 728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-13.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/2/25/ Run-a-Program-from-the-Command-Line-on-Linux-Step-13.jpg/v4-728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-13. jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser-output”></div>”}
Type source ~/.bashrc and then press ↵ Enter . This command will load the newly updated $PATH variable into the current session. [4] X Research Sources
Image titled Run a Program from the Command Line on Linux Step 14

Image titled Run a Program from the Command Line on Linux Step 14

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/b/b4/Run-a-Program-from-the-Command-Line-on-Linux-Step-14.jpg/v4- 728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-14.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/b/b4/ Run-a-Program-from-the-Command-Line-on-Linux-Step-14.jpg/v4-728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-14. jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser-output”></div>”}
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 will be able to launch the program with a simple operation, which is to enter the program name and then press Enter .

Install and uninstall programs on Terminal

Image titled Run a Program from the Command Line on Linux Step 15

Image titled Run a Program from the Command Line on Linux Step 15

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/c/c6/Run-a-Program-from-the-Command-Line-on-Linux-Step-15.jpg/v4- 728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-15.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/c/c6/ Run-a-Program-from-the-Command-Line-on-Linux-Step-15.jpg/v4-728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-15. jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser-output”></div>”}
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).
Image titled Run a Program from the Command Line on Linux Step 16

READ More:   How to Paint Nails

Image titled Run a Program from the Command Line on Linux Step 16

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/d/d3/Run-a-Program-from-the-Command-Line-on-Linux-Step-16.jpg/v4- 728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-16.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/d/d3/ Run-a-Program-from-the-Command-Line-on-Linux-Step-16.jpg/v4-728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-16. jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser-output”></div>”}
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.
Image titled Run a Program from the Command Line on Linux Step 17

Image titled Run a Program from the Command Line on Linux Step 17

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/e/ee/Run-a-Program-from-the-Command-Line-on-Linux-Step-17.jpg/v4- 728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-17.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/e/ee/ Run-a-Program-from-the-Command-Line-on-Linux-Step-17.jpg/v4-728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-17. jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser-output”></div>”}
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.
Image titled Run a Program from the Command Line on Linux Step 18

Image titled Run a Program from the Command Line on Linux Step 18

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/6/60/Run-a-Program-from-the-Command-Line-on-Linux-Step-18.jpg/v4- 728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-18.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/6/60/ Run-a-Program-from-the-Command-Line-on-Linux-Step-18.jpg/v4-728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-18. jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser-output”></div>”}
Type the command 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.
Image titled Run a Program from the Command Line on Linux Step 19

Image titled Run a Program from the Command Line on Linux Step 19

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/5/56/Run-a-Program-from-the-Command-Line-on-Linux-Step-19.jpg/v4- 728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-19.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/5/56/ Run-a-Program-from-the-Command-Line-on-Linux-Step-19.jpg/v4-728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-19. jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser-output”></div>”}
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. [5] X Research Sources
  • Image titled Run a Program from the Command Line on Linux Step 20

    Image titled Run a Program from the Command Line on Linux Step 20

    {“smallUrl”:”https://www.wikihow.com/images_en/thumb/a/ac/Run-a-Program-from-the-Command-Line-on-Linux-Step-20.jpg/v4- 728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-20.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/a/ac/ Run-a-Program-from-the-Command-Line-on-Linux-Step-20.jpg/v4-728px-Run-a-Program-from-the-Command-Line-on-Linux-Step-20. jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser-output”></div>”}
    Type the program name and press ↵ Enter . After the program is installed, you can proceed to launch it on Terminal with a simple operation, that is, enter the program name and press Enter .
  • X

    This article is co-authored by a team of editors and trained researchers who confirm the accuracy and completeness of the article.

    The wikiHow Content Management team carefully monitors the work of editors to ensure that every article is up to a high standard of quality.

    This article has been viewed 4,760 times.

    Most Linux distributions have a graphical user interface that allows us to open programs just by clicking on the program icon in the Apps menu. However, sometimes you may want to launch programs from Terminal. Terminal is a powerful tool that allows users to launch programs and manage Linux systems through keyboard commands. This wikiHow teaches you how to launch programs from Terminal on Linux.

    Thank you for reading this post How to Launch Programs from Command Line on Linux at Tnhelearning.edu.vn You can comment, see more related articles below and hope to help you with interesting information.

    Related Search:

    Related Posts

    How to Create Curved Text in Photoshop
    How to fall asleep faster
    How to Install FBReader to Read eBooks

    Category: How To

    Previous Post: « How to Invite Someone on a Video Date
    Next Post: How to Copy Music to Portable Storage »

    Copyright © 2025 · Tnhelearning.edu.vn - Useful Knowledge