How To Run Program In Linux – Using Terminal Multiplexer Tools

Executing a program in Linux often starts with navigating to its directory and using the dot-slash prefix. If you are new to Linux, understanding how to run program in Linux can feel confusing at first. But once you learn the basics, it becomes second nature.

Linux offers many ways to run programs. You can use the terminal, file managers, or desktop shortcuts. This guide covers all the common methods. You will learn the commands, permissions, and tricks to execute any program.

How To Run Program In Linux

Before you run anything, you need to know what type of program it is. Linux programs come as binaries, scripts, or packages. Each type has its own method.

Running A Binary Program

A binary program is a compiled executable file. These files often have no extension or end with .bin or .run. To run one, you need execute permission.

  1. Open a terminal.
  2. Navigate to the directory containing the file. Use cd /path/to/program.
  3. Type ./program_name and press Enter.

The dot-slash (./) tells Linux to look in the current directory. Without it, the system searches PATH directories only.

Running A Script

Scripts are text files with commands. Common script types are Bash (.sh), Python (.py), and Perl (.pl). You run them with an interpreter.

  • For Bash: bash script.sh or ./script.sh (if executable)
  • For Python: python3 script.py
  • For Perl: perl script.pl

Make sure the script has a shebang line at the top. For example, #!/bin/bash or #!/usr/bin/python3.

Running A Program From The System PATH

If a program is installed system-wide, you can run it from anywhere. Just type the program name. Examples: firefox, gedit, ls.

You do not need the dot-slash prefix. The system finds the program automatically.

Setting Execute Permissions

Many programs refuse to run without proper permissions. You must grant execute permission first.

Use the chmod command:

chmod +x program_name

This adds execute permission for the owner. You can also use:

chmod 755 program_name

This sets read, write, and execute for the owner, and read and execute for others.

Checking Permissions

List the file details with ls -l. Look for the x in the output. Example: -rwxr-xr-x means it is executable.

Running Programs From The Desktop

Not everyone likes the terminal. You can run programs using the graphical interface too.

Using The File Manager

Open your file manager (Nautilus, Dolphin, Thunar). Navigate to the program file. Double-click it. If it is executable, it will run. If not, right-click and choose “Run as a program” or “Properties” > “Permissions” > “Allow executing file as program”.

Creating A Desktop Shortcut

Desktop shortcuts make launching programs easy. Create a .desktop file.

  1. Create a new file named program.desktop.
  2. Add these lines:
[Desktop Entry]
Name=My Program
Exec=/path/to/program
Type=Application
Terminal=false

Make the file executable with chmod +x program.desktop. Then double-click it.

Running Programs With Sudo

Some programs need root privileges. Use sudo before the command.

sudo ./program_name

You will be prompted for your password. Be careful with sudo. It can modify system files.

When To Use Sudo

  • Installing software
  • Modifying system settings
  • Running services
  • Accessing protected files

Running Programs In The Background

Sometimes you want a program to run without blocking the terminal. Use the ampersand (&) at the end.

./program_name &

The program starts, and you get your prompt back. To bring it to the foreground, type fg.

Using Nohup

If you close the terminal, background jobs stop. Use nohup to keep them running.

nohup ./program_name &

Output goes to nohup.out by default.

Running Programs With Arguments

Many programs accept arguments. Arguments modify behavior. You add them after the program name.

./program_name --option value

Example: ./myapp --config config.txt

Check the program’s help menu with --help or -h.

Running Programs From A Different Directory

You do not have to be in the program’s directory. Use the full path.

/home/user/programs/myapp

Or use a relative path: ../programs/myapp

Running Programs With Wine

Windows programs do not run natively on Linux. Use Wine to run them.

  1. Install Wine: sudo apt install wine (Ubuntu/Debian)
  2. Navigate to the Windows executable.
  3. Run: wine program.exe

Wine creates a virtual Windows environment. Not all programs work perfectly.

Running Programs In A Virtual Environment

For Python programs, use virtual environments. This isolates dependencies.

  1. Create a virtual environment: python3 -m venv myenv
  2. Activate it: source myenv/bin/activate
  3. Run your Python script: python script.py
  4. Deactivate when done: deactivate

Running Programs From The Application Menu

Most Linux desktops have an application menu. Click the menu icon (often top-left). Search for the program name. Click it to run.

If the program is not listed, you can add it manually. Use the menu editor or create a .desktop file in ~/.local/share/applications/.

Running Programs At Startup

You can make programs start automatically when you log in.

Using The Desktop Environment

Go to “Startup Applications” in system settings. Add a new entry. Point it to the program path.

Using Crontab

Edit your crontab: crontab -e. Add a line like:

@reboot /path/to/program

This runs the program at every reboot.

Running Programs With Systemd

For services or daemons, use systemd. Create a service file.

  1. Create /etc/systemd/system/myapp.service:
[Unit]
Description=My App

[Service]
ExecStart=/path/to/program
Restart=always

[Install]
WantedBy=multi-user.target
  1. Enable it: sudo systemctl enable myapp
  2. Start it: sudo systemctl start myapp

Systemd manages the program lifecycle. It can restart on crashes.

Running Programs In A Container

Containers like Docker and Podman run programs in isolated environments.

Example with Docker:

docker run --rm -it ubuntu bash

This runs a Bash shell inside an Ubuntu container. You can run any program inside.

Common Errors And Fixes

You may encounter errors when running programs. Here are common ones.

Permission Denied

This means the file is not executable. Use chmod +x.

Command Not Found

The program is not in PATH. Use the full path or add the directory to PATH.

To add a directory: export PATH=$PATH:/path/to/program

No Such File Or Directory

Check the path. Use ls to confirm the file exists.

Segmentation Fault

The program crashed. It may be incompatible with your system. Check for updates or dependencies.

Running Programs With Different Users

You can run a program as another user. Use the su or sudo -u command.

sudo -u username ./program

This runs the program with that user’s permissions.

Running Programs In A Terminal Emulator

Some programs need a terminal to run. Use a terminal emulator like GNOME Terminal, Konsole, or xterm.

Open the emulator, then run the program inside it.

You can also run a program in a new terminal window:

gnome-terminal -- ./program

Running Programs With Environment Variables

Environment variables affect program behavior. Set them before running.

export VAR=value

./program

Or set them inline:

VAR=value ./program

Running Programs With Debugging

If a program misbehaves, run it with debugging tools.

  • strace traces system calls: strace ./program
  • gdb debugs the program: gdb ./program
  • valgrind checks memory: valgrind ./program

Running Programs From The Web

You can download and run programs from the internet. Be cautious. Only download from trusted sources.

  1. Download the file with wget or curl.
  2. Make it executable.
  3. Run it.

Example:

wget https://example.com/program

chmod +x program

./program

Running Programs With Aliases

Create aliases for frequently used programs. Add them to ~/.bashrc.

alias myapp='/path/to/program --option'

Then type myapp to run it.

Running Programs With Keyboard Shortcuts

You can assign keyboard shortcuts to run programs. Go to keyboard settings in your desktop environment. Add a custom shortcut. Set the command to the program path.

Running Programs On Remote Servers

Use SSH to run programs on remote Linux machines.

ssh user@server /path/to/program

Or log in first, then run it.

Running Programs With Cron

Cron runs programs at scheduled times. Edit your crontab:

crontab -e

Add a line like:

0 5 * * * /path/to/program

This runs the program every day at 5 AM.

Running Programs With Systemd Timers

Systemd timers are an alternative to cron. Create a timer file and a service file.

Example timer file /etc/systemd/system/myapp.timer:

[Unit]
Description=Run My App Daily

[Timer]
OnCalendar=daily

[Install]
WantedBy=timers.target

Enable and start the timer.

Running Programs In Different Runlevels

Linux has runlevels that define system state. You can run programs at specific runlevels using init scripts or systemd targets.

Running Programs With Flatpak And Snap

Flatpak and Snap are package managers that sandbox applications.

To run a Flatpak app:

flatpak run com.example.app

To run a Snap app:

snap run appname

These programs are isolated from the rest of the system.

Running Programs With AppImage

AppImage is a portable format. Download the AppImage file, make it executable, and run it.

chmod +x app.AppImage

./app.AppImage

No installation needed.

Running Programs With Python Virtual Environments

For Python programs, use virtual environments to avoid dependency conflicts.

  1. Create env: python3 -m venv myenv
  2. Activate: source myenv/bin/activate
  3. Install dependencies: pip install -r requirements.txt
  4. Run: python main.py

Running Programs With Java

Java programs come as JAR files. Run them with:

java -jar program.jar

Ensure Java is installed: java -version.

Running Programs With Node.js

Node.js programs are JavaScript files. Run them with:

node app.js

Install Node.js first if needed.

Running Programs With Ruby

Ruby scripts run with:

ruby script.rb

Running Programs With Go

Go programs are compiled binaries. Run them directly:

./program

Running Programs With Rust

Rust programs are also compiled. Run the binary.

Running Programs With Shell Scripts

Shell scripts automate tasks. Create a file with commands, make it executable, and run it.

Example myscript.sh:

#!/bin/bash
echo "Hello"
./program

Run: ./myscript.sh

Running Programs With Make

Make is a build tool. It runs commands defined in a Makefile. Use make target.

Running Programs With Docker Compose

Docker Compose runs multi-container applications. Define services in docker-compose.yml. Run docker-compose up.

Running Programs With Ansible

Ansible runs programs on remote servers. Write playbooks and execute them.

ansible-playbook playbook.yml

Running Programs With Screen Or Tmux

Screen and Tmux let you run programs in persistent sessions. Detach and reattach later.

Example with Tmux:

tmux new -s mysession

./program

Press Ctrl+B then D to detach. Reattach with tmux attach