/>
X

How to install Linux applications from the command line

Jack Wallen demonstrates how to install software from the command line on Ubuntu, AlmaLinux, Arch Linux, and openSUSE.
jack-wallen-thumb4x3.jpg
Written by Jack Wallen, Contributing Writer on

Linux isn't nearly as hard as you think it is. In fact, Linux has become one of the easiest desktop and server operating systems on the planet. How is that possible? For one thing, modern Linux distributions make it so you never need to touch the command-line interface. That's right, you can do everything you need within the point-and-click GUI–just like you do with macOS and Windows. It really is that easy.

And though you certainly can do everything from within the well-designed GUI tools, there might come a time when you need to (or just want to) make use of the terminal. One such occasion might be if you've deployed Linux as a server without a desktop environment. You might want to have a Linux server on your home LAN to deploy things to, including web servers, file servers, media streaming platforms, and more. When that's the case, you'll need to know how to install applications from the command line. 

For example, you want to install the Nextcloud cloud-based content management and collaboration platform. Or maybe you want to build an entire website from scratch and serve it up via the Apache web server. You might even want a full LAMP (Linux Apache MySQL PHP) stack on your server.

Regardless of why, you'll need to know how to install those applications from the CLI (command-line interface). I'm going to show you how. Let's stick with our LAMP stack example to illustrate how to do this on Ubuntu, AlmaLinux, Arch Linux, and openSUSE (which should cover most distributions).

Ready? Let's go.

Installing a LAMP stack on Ubuntu-based distributions

Our first demonstration will be on the user-friendly Ubuntu distribution. Ubuntu uses the APT (Advanced Packaging Tool) package manager and makes installing a full LAMP stack incredibly easy. A basic APT installation looks like this:

sudo apt install PACKAGENAME -y

Where PACKAGENAME is the name of the software you want to install. Before you run the installation, you might want to first update APT with:

sudo apt update

With APT updated, you're ready to install the LAMP stack. One of the handy tricks with Ubuntu and the LAMP stack is that you can install it all with a single simple command, which is:

sudo apt install lamp-server^ -y

If you don't want to go that route, you can install the packages individually. First install the Apache web server with:

sudo apt install apache2 -y

Next, install the MySQL database server with:

sudo apt install mysql-server -y

You'll then install the latest version of PHP with:

sudo apt install php8.1-fpm php8.1 libapache2-mod-php8.1 php8.1-common php8.1-mysql php8.1-xml php8.1-xmlrpc php8.1-curl php8.1-gd php8.1-imagick php8.1-cli php8.1-imap php8.1-mbstring php8.1-opcache php8.1-soap php8.1-zip php8.1-intl php8.1-bcmath unzip -y

Of course, you can opt to do it all with the single-line command shown above.

Installing a LAMP stack on AlmaLinux

AlmaLinx is a Red Hat Enterprise Linux-based distribution, and the installation requires you to install each package individually. 

First, install the web server with:

sudo dnf install httpd -y

Next, install the MySQL database server with:

sudo dnf install mysql-server mysql -y

Finally, you install PHP with:

sudo dnf install php -y

Installing a LAMP stack on Arch Linux

Arch Linux is nearly as user-friendly as is either Ubuntu or AlmaLinux. Arch Linux uses the pacman package manager and must first be updated with:

sudo pacman -Syu

Once updated, install Apache with:

sudo pacman -S apache

Next, install the MySQL database server with:

sudo pacman -S mysql

Finally, install PHP with:

sudo pacman -S php php-apache

The options used above are:

  • S - Synchronize packages

  • y - Download a fresh copy of the master package database.

  • u - Upgrade all out-of-date software

Installing a LAMP server on openSUSE

Finally, we'll install the LAMP server on openSUSE, which uses the zypper package manager. Update zypper with:

sudo zypper update

Install Apache on openSUSE with:

sudo zypper install apache2

Install the MariaDB database with:

sudo zypper install mariadb mariadb-client mariadb-tools

Install PHP7 with:

sudo zypper install php7 php7-mysql apache2-mod_php7

The commonality

Except for Arch Linux, the installation of software is generally handled like so:

sudo PACKAGEMANAGER install SOFTWARE

Where PACKAGEMANAGER is the package manager used by the distribution and SOFTWARE is the name of the software to be installed.

The same holds true for removing software, as in:

sudo PACKAGEMANAGER remove SOFTWARE

Again, where PACKAGEMANAGER is the package manager used by the distribution and SOFTWARE is the name of the software to be installed.

To better illustrate this, you can install the Firefox web browser on each platform like so:

  • Ubuntu - sudo apt install firefox -y

  • AlmaLinux - sudo dnf install firefox -y

  • openSUSE - sudo zypper firefox -y

Of course, with Arch Linux, that command would be:

sudo pacman -S firefox -y

And that's really the basics of installing software from the Linux command line. It really is so easy anyone who can type can install software from the Linux command line.

Related

Need a free Slack alternative? How to quickly deploy Rocket.Chat
The first window of the Rocket.Chat installation wizard.

Need a free Slack alternative? How to quickly deploy Rocket.Chat

Collaboration
How to install Android apps on your Chromebook
The Chrome OS system tray popup.

How to install Android apps on your Chromebook

Productivity
How to enable Linux on your Chromebook (and why you should)
The Chrome OS system tray popup menu.

How to enable Linux on your Chromebook (and why you should)

Linux