Loading programs in linux

Brilliant Ways on How to Run a Program in Linux

If you are new to Linux, particularly the command line, and want to learn how to run a program in Linux, you’ve come to the right spot. Running programs in Linux is no different than how it’s done in Windows. Easy to say, right? But no worries, you’ll get to run any program in no time.

In this tutorial, you’ll learn many ways to run programs in Linux, both via GUI and a command-line environment. From a novice Linux user to a power user, you will find knowing these methods to run a program helpful.

Prerequisites

Ubuntu Desktop 15.04 or later – Ensure you have a Linux host ready to go. This tutorial uses Ubuntu 15.04 (Desktop version) with GNOME installed, but any newer distribution should work similarly.

Launching Programs with the Application (App) Launcher

There are generally multiple ways to run a program within Windows, and Linux is no different. We will start with the most common way to run a program using the Launcher.

The most common method to run programs in Linux is to use the Launcher. The Launcher is a bar similar to the Windows start menu that contains a list of icons you can click on to run programs.

In Ubuntu, the App Launcher is located on the left side of the screen, as you can see below, containing default commonly run applications. To open the program, simply click the icon representing the program.

Accessing the Launcher programs through GUI

Launching Programs with the Applications Menu (Unity Dash)

You can also run programs in Ubuntu Linux with Unity Dash. The Applications Menu or Unity Dash is a handy way to search for and run programs in GNOME. To use the Applications Menu, click on the Ubuntu button in the top left corner.

Selecting the icon to search and launch programs using the Unity Dash

You’ll see below that the menu opens a search bar with any recently run programs.

Search for the program you want to run using the Unity Dash in older versions of Ubuntu

Type in the correct name of the program you are looking for (i.e Firefox) and it will appear, then select it to launch the program.

In Ubuntu Linux v20.04+, Unity Dash has been replaced with Activities in the upper left of your screen but the process to run a program remains the same.

Using the Run Command to Launch Program

Another way to launch programs in Linux is to use the Run command. The Run command is a handy way to quickly run a program in Linux by typing the program and executing it.

Читайте также:  Настройка сети между linux

To run programs via the Run command, select the Alt-F2 to open the Run Command box.

You can also hit Alt-F2 as a shortcut to the run command.

Using the run command

Next, type the name of the program you want to run. In this example, you’ll run the Terminal application, type terminal, select the Terminal icon and hit Enter.

Selecting the icon or hitting enter will launch the program

You’ll see below that Linux will launch the Terminal application.

Running Programs Using Hot Keys

If you’re more of a keyboard ninja and would rather skip the mouse like we started with in the last example, you can also run programs with hotkeys. In all Linux distros, you can use the Super Key (Windows Key) + A. The Super Key will bring up all applications in alphabetical order and a text box to type in the name of a program, as shown below.

You can type the name of the program in the search box to navigate to the program or click on the program with your mouse if it appears immediately.

Running Programs Using Hot Keys

Setting Up Keyboard Shortcuts to Run Programs in Linux

Now that you have learned the GUI options to run programs, the remainder of this tutorial will focus on using non-GUI-based options to run programs. Let’s first begin with keyboard shortcuts. Using keyboard shortcuts can remove a lot of clicking around.

To set up keyboard shortcuts in Ubuntu:

1. Select the icon in the top left corner again and Keyboard Shortcut. The Keyboard application should show up below. When it does, click on it.

Selecting the icon and launching the Keyboard Shortcut

2. In the Keyboard application, click on the Shortcut tab.

In Ubuntu 20.04 and newer, selecting Keyboard Shortcut from the Activities menu brings you directly to the Shortcuts tab.

Accessing the Shortcuts Tab

3. Click on the + icon to create a new keyboard shortcut. Ubuntu will direct you to the Custom Shortcuts section.

Adding a New Shortcut

4. Next, enter a descriptive Name for the shortcut key and provide the Command (program) to execute and click Apply.

Entering the name and program to use for the Shortcut

When Ubuntu creates the shortcut, you’ll see that the Name shows up under Custom Shortcuts but it’s disabled.

Seeing the Created, but not Active Shortcut Key

5. Now, click on the Disabled text as shown above and press the desired keyboard shortcut such as Ctrl+T. Once you type your desired shortcut, it will show up, as shown below.

Activating the Shortcut

6. Finally, launch the application by pressing the keyboard shortcut!

Running a Program within the Terminal

Although if you’re a newcomer to Linux, chances are you’ll be running programs with the GUI but if you need to use the command line for any reason, the Terminal makes it easy to do so. The Terminal is a command-line application that allows you to manage all facets of Linux with the keyboard.

To run programs in the Terminal, open the App Launcher (or Activities) in the upper left corner and run the Terminal application as shown below.

Accessing the Terminal

When the Terminal opens, as shown below, simply type the name of the program and press Enter.

Running programs in the Terminal will not work for all programs. Some programs may not be in the PATH.

Launching the program end result

Conclusion

In this tutorial, you’ve learned many different methods to run programs in Linux. Using both GUI-based and command-line-based methods, you should now know how to launch programs wherever you are within Linux.

Читайте также:  Linux mint vs manjaro kde

Try installing programs in Linux such as the tutorial to install a common program such as Docker for practice and then run it using a shortcut, command line, or GUI Interface. Which way will you use most often to run your favorite programs?

Hate ads? Want to support the writer? Get many of our tutorials packaged as an ATA Guidebook.

Источник

How to start program at Linux boot automatically

Linux startup consists of several stages, during which you can configure a program to start automatically. This can be a single command, a sequence of commands, or an executable shell script. However, startup procedures may vary between different Linux distributions and versions.

Modern Linux systems boot into systemd, while older Linux versions utilize System V init. Regardless, both systems will execute cron and rc.local before loading the desktop environment, such as GNOME or KDE. In contrast, server-based Linux distributions do not load a desktop environment and instead provide a login prompt at the console. After logging in, the default shell like Bash runs.

Methods to automatically run program on Linux startup:

Running a program automatically on Linux startup via systemd

systemd is the standard system and service manager in modern Linux, responsible for executing and managing programs during startup, among other tasks. Compatible programs will include service unit files used by systemd to manage the program’s execution.

To configure systemd to run a program automatically during Linux startup, follow these steps:

$ sudo systemctl list-unit-files --type=service [sudo] password for user: UNIT FILE STATE accounts-daemon.service enabled apparmor.service enabled apport-autoreport.service static apport-forward@.service static apport.service generated apt-daily-upgrade.service static apt-daily.service static atd.service enabled autovt@.service enabled blk-availability.service enabled bootlogd.service masked bootlogs.service masked bootmisc.service masked checkfs.service masked checkroot-bootclean.service masked checkroot.service masked cloud-config.service enabled cloud-final.service enabled cloud-init-local.service enabled cloud-init.service enabled console-getty.service disabled ##### snipped #####

You’ll have to create your own service unit if it’s a custom program or if your program doesn’t come with one during installation
Related: Creating and modifying systemd unit files

$ sudo systemctl is-enabled mysql disabled
$ sudo systemctl enable mysql Synchronizing state of mysql.service with SysV service script with /lib/systemd/systemd-sysv-install. Executing: /lib/systemd/systemd-sysv-install enable mysql Created symlink /etc/systemd/system/multi-user.target.wants/mysql.service → /lib/systemd/system/mysql.service.
$ sudo systemctl is-enabled mysql enabled

Running a program automatically on Linux startup via cron

cron is a daemon used to execute scheduled commands stored in the cron job table (crontab), which is unique for each user in the system. It starts during system boot, either via systemd or System V init, and you can schedule your program to run during system boot by following these steps:

You’re required to select an editor for the crontab if this is the first time the user uses the command.

$ crontab -e no crontab for user - using an empty one Select an editor. To change later, run 'select-editor'. 1. /bin/nano 

A crontab will be created for the user running the command and will be executed using the privileges of the user. If you need your program to run as the root user, run crontab -e as the root user itself.

# m h dom mon dow command @reboot
@reboot /sbin/ip addr | grep inet\ | tail -n1 | awk '< print $2 >' > /etc/issue && echo "" >> /etc/issue
$ crontab -e crontab: installing new crontab $
$ crontab -l # m h dom mon dow command @reboot /sbin/ip addr | grep inet\ | tail -n1 | awk '< print $2 >' > /etc/issue && echo "" >> /etc/issue

Running a program automatically on Linux startup via rc.local

rc.local is a legacy script from the System V init system, executed before displaying a login screen for the desktop environment or terminal login prompt. It is typically a Bash shell script capable of running any commands.

To configure your rc.local script, follow these steps:

As the root user, open or create the /etc/rc.local file using your preferred editor if it doesn't exist.

#!/bin/bash /sbin/ip addr | grep inet\ | tail -n1 | awk '< print $2 >' > /etc/issue echo "" >> /etc/issue exit 0

Running a program automatically on GNOME startup

GNOME is the default desktop environment for Linux distributions like Ubuntu and Red Hat. You can configure GNOME to run programs upon user login by following the instructions in the linked article:

Running a program automatically on KDE startup

KDE is another popular Linux desktop environment and the default for Kubuntu and openSUSE. It can also be configured to run programs when a user logs in, as detailed in the related article:

Running a program automatically on new Bash session

A new shell program will be spawned when you start your terminal session. Bash is the default shell for most Linux distributions, and when started, it will look for the following files in the particular starting a terminal session, a new shell program will be spawned. Bash is the default shell for most Linux distributions and, when initiated, looks for and executes the following files in order:

/etc/profile ~/.bash_profile ~/.bash_login ~/.profile

These files contain commands and logic for setting up environment variables and running required programs in the Bash language. They are also typically configured to execute other files, such as /etc/bashrc, /etc/bash.bashrc, and ~/.bashrc.

You can edit any of these files to run your program when a Bash session is started. Below is a part of a typical ~/.bashrc file:

PS1='$\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\] \$ ' PATH=/home/user/bin:$PATH export EDITOR=/usr/bin/vim alias ll="ls -l"

Author: Mohd Shakir Zakaria
Mohd Shakir Zakaria, a proficient cloud architect, is deeply rooted in development, entrepreneurship, and open-source advocacy. As the founder of Simplified Guide, he combines these passions to help others navigate the intricate world of computing. His expertise simplifies complex tech concepts, making them accessible to everyone. Discuss the article:

Comment anonymously. Login not required.

Источник

Оцените статью
Adblock
detector