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 : http://www.greenwoodsoftware.com/less/ 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 MAINTAINER nixCraft 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 EXPOSE 80 ENTRYPOINT /usr/sbin/httpd -DFOREGROUND
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
$ 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 127.0.0.1:8888
Test our container
$ sudo firewall-cmd --add-port 8888/tcp
See “RHEL 8 FirewallD” or “CentOS 8 FirewallD” tutorial about opening ports.
Conclusion
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
- Share on Twitter • Facebook • 2 comments... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Is podman same as Docker? Why should I use podman over Docker? Can you install the podman on Ubuntu aws ec2 service?
Podman is not Docker. But, both em follow similar syntax. See linked page at the bottom of this tutorial.