How to install less on CentOS / RHEL / Fedora

One of my PHP and bash scripts depends upon less command to display the help system to other users. But, whenever they run less on a particular version of CentOS or RHEL cloud server, they get an error that reads as: “bash: less: command not found.” How do I install less utility on CentOS or RHEL (Red Hat Enterprise Linux)/Fedora Linux server? How can I configure Linux containers such as Docker or Podman to install less automatically?

Less is a command for Linux and Unix-like systems. It is similar to more command but comes with many features and options. For example, less doesn’t have to read the complete input before starting, so with a large input file, it starts faster than a typical text editor. Less may not be installed on cloud images, especially Linux containers, to save disk and image size. This page explains how to install less on a CentOS or RHEL version 6/7/8.

Searching for less package

Open the terminal application or ssh session and then type the following dnf command/yum command to find out less package name on your version of CentOS or RHEL system:
$ sudo yum whatprovides '*bin/less'

Last metadata expiration check: 1:25:50 ago on Sun Aug 23 10:15:44 2020.
less-530-1.el8.x86_64 : A text file browser similar to more, but better
Repo        : BaseOS
Matched from:
Other       : *bin/less

Getting information about less package on RHEL or CentOS

Again use the following command:
$ sudo yum info less

Last metadata expiration check: 1:27:35 ago on Sun Aug 23 10:15:44 2020.
Available Packages
Name         : less
Version      : 530
Release      : 1.el8
Architecture : x86_64
Size         : 164 k
Source       : less-530-1.el8.src.rpm
Repository   : BaseOS
Summary      : A text file browser similar to more, but better
URL          :
License      : GPLv3+ or BSD
Description  : The less utility is a text file browser that resembles more, but has
             : more capabilities.  Less allows you to move backwards in the file as
             : well as forwards.  Since less doesn't have to read the entire input file
             : before it starts, less starts up more quickly than text editors (for
             : example, vi).
             : You should install less because it is a basic utility for viewing text
             : files, and you'll use it frequently.

Installing less on CentOS / RHEL

So far, we figured how to package name that can install less utility on our CentOS or RHEL cloud server. Now all you have to do is type the following command to install the same:
$ sudo yum update
$ sudo yum install less

A note about Fedora Linux cloud user

Use the dnf command as follows:
$ sudo dnf update
$ sudo dnf install less

Install less with Docker or Podman container

Create project dir using the mkdir command and cd into it using the cd command:
$ mkdir apache2
$ cd apache2
$ echo 'Podman/Docker apache2 demo by nixCraft' > index.html
$ vim Dockerfile

Here is a sample Dockerfile:

FROM centos:8
LABEL Remarks="CentOS 8 test image for installing less along with Apache2"
# Install apache2 with less
RUN yum -y update && \
yum -y install httpd less && \
yum clean all
# Sample index.html for test 
COPY index.html /var/www/html/index.html
# Port and set entry point for container 

Build it as follows either using the podman command/docker command:
$ sudo docker build --tag centos:apache2 -f ./Dockerfile
## OR use podman ##
$ sudo podman build --tag centos:apache2 -f ./Dockerfile

Linux container installing less utility

List images and run it:
$ sudo docker images
$ sudo docker run -d -p 8888:80 --name nixcraft-apache2 --rm centos:apache2
$ sudo docker ps
$ sudo docker port nixcraft-apache2
$ curl

Test our container

For remote access to our container open TCP port 8888 using the firewall-cmd command:
$ sudo firewall-cmd --add-port 8888/tcp
See “RHEL 8 FirewallD” or “CentOS 8 FirewallD” tutorial about opening ports.


And there you have it, and you learned how to install less on CentOS or RHEL 7 or 8 including Fedora Linux using CLI and Docker/Podman Linux container.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 2 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
2 comments… add one
  • Lobster Aug 24, 2020 @ 7:34

    Is podman same as Docker? Why should I use podman over Docker? Can you install the podman on Ubuntu aws ec2 service?

    • 🐧 Vivek Gite Aug 24, 2020 @ 9:22

      Podman is not Docker. But, both em follow similar syntax. See linked page at the bottom of this tutorial.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum