How to Launch Programs from Command Line on Linux

Launch the program from Terminal

How to Launch Programs from Command Line on Linux Picture 1

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.

How to Launch Programs from Command Line on Linux Picture 2

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

How to Launch Programs from Command Line on Linux Picture 3

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.

How to Launch Programs from Command Line on Linux Picture 4

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.

How to Launch Programs from Command Line on Linux Picture 5

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.

How to Launch Programs from Command Line on Linux Picture 6

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

How to Launch Programs from Command Line on Linux Picture 7

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.

How to Launch Programs from Command Line on Linux Picture 8

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.

How to Launch Programs from Command Line on Linux Picture 9

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.

How to Launch Programs from Command Line on Linux Picture 10

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.

How to Launch Programs from Command Line on Linux Picture 11

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

How to Launch Programs from Command Line on Linux Picture 12

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.

How to Launch Programs from Command Line on Linux Picture 13

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

How to Launch Programs from Command Line on Linux Picture 14

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

How to Launch Programs from Command Line on Linux Picture 15

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).

How to Launch Programs from Command Line on Linux Picture 16

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.

How to Launch Programs from Command Line on Linux Picture 17

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.

How to Launch Programs from Command Line on Linux Picture 18

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.

How to Launch Programs from Command Line on Linux Picture 19

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.

How to Launch Programs from Command Line on Linux Picture 20

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.

4 ★ | 1 Vote

May be interested

  • The Nox App Player command line parameters supportThe Nox App Player command line parameters support
    this article will list for you some command line parameters that nox app player supports (from version 3.0 and above). these command line parameters are used to set up system settings, launch applications and control nox.
  • How to manage Linux services using SystemdHow to manage Linux services using Systemd
    one of the most important skills that any new systemd user needs to learn is how to manage computer services. this article will teach you the basics: start, stop, enable and disable services from the linux command line.
  • How to send email using the command line in LinuxHow to send email using the command line in Linux
    in this article, i will show you how to use the linux command to send mail with a script. in addition, it is the sending of attachments from the command line.
  • Instructions for using find command in LinuxInstructions for using find command in Linux
    the find command is one of the most important and handy commands on a linux system. as its name suggests, the command can find files on a linux pc based on a variety of conditions and variables you set.
  • How to use the which command in LinuxHow to use the which command in Linux
    the which command in linux determines the executable binary, which will execute when you issue a command to the shell. if you have different versions of the same program on your computer, you can use which to find out which shell will use.
  • The dd command in Linux, How to use the dd commandThe dd command in Linux, How to use the dd command
    dd is a command line utility for unix-like and unix operating systems, with the main purpose of converting and copying files.
  • How to Manage Users in LinuxHow to Manage Users in Linux
    unlike windows, as a unix-like system, linux was conceived of as a multi-user system from its inception. the following sections deal with user management through the linux command line. type adduser -d /home/users/ into the command line.
  • 5 free websites and online games to learn about the Linux command line5 free websites and online games to learn about the Linux command line
    linux is popular for its reliability and many practical applications. if you want to know more about linux, here are 5 websites that will help you learn it interactively.
  • 20+ essential Linux security commands20+ essential Linux security commands
    here are some of the most important security commands for everyday work on linux systems. if you're interested in security issues on your linux system, don't ignore these helpful security commands.
  • Search for files and directories in Linux using the command line interfaceSearch for files and directories in Linux using the command line interface
    you can use the graphical file management utility to find files in linux like nautilus in gnome, dolphin in kde and thunar in xfce. however, there are several ways to use the command line to find files in any linux desktop management utility.