Table of Contents
In this article, i will take you through the best steps to install perl on Ubuntu 20.04. Perl (Practical Extraction and Reporting Language) is a very popular and powerful language for String Handling and String Processing. You will see the usage of Perl as web scripting language along with other web technologies and frameworks. It is used for writing Server side tasks. Perl can also be used to interface front end languages like HTML with the backend Databases. It has very robust modules available to interact with other programming languages in various platforms. We will go through the steps to install Perl on Ubuntu 20.04 systems in great detail.
Install Perl on Ubuntu 20.04
Also Read: 17 traceroute command examples to Identify Network Problems in Linux/Unix
Step 1: Prerequisites
a) You need to have a running Ubuntu 20.04
Server.
b) You should have apt
tool installed in your Server. To Know more about apt get tool, you can check 20 Useful apt get examples on Ubuntu.
d) You should have sudo
access to run Privileged Commands. Please Check How to Add User to Sudoers to know more about providing sudo
access to the User.
Step 2: Update Your Server
Before going through the steps to install perl on Ubuntu 20.04 it is always recommended to update your system using apt update -y
or apt-get update -y
command as shown below. This command will download and install all the latest available updates from Ubuntu Repository.
root@localhost:~# apt update -y Hit:1 http://in.archive.ubuntu.com/ubuntu focal InRelease Get:2 http://in.archive.ubuntu.com/ubuntu focal-updates InRelease [111 kB] Get:4 http://in.archive.ubuntu.com/ubuntu focal-backports InRelease [98.3 kB] Get:5 http://security.ubuntu.com/ubuntu focal-security InRelease [107 kB] Ign:3 https://pkg.jenkins.io/debian-stable binary/ InRelease Hit:6 https://pkg.jenkins.io/debian-stable binary/ Release Get:7 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [359 kB] Get:8 http://in.archive.ubuntu.com/ubuntu focal-updates/main i386 Packages [212 kB] Get:9 http://in.archive.ubuntu.com/ubuntu focal-updates/main Translation-en [136 kB] Get:10 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 DEP-11 Metadata [209 kB] Get:11 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 c-n-f Metadata [9,464 B] Get:12 http://in.archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [166 kB] Get:13 http://in.archive.ubuntu.com/ubuntu focal-updates/universe i386 Packages [91.3 kB] Get:14 http://in.archive.ubuntu.com/ubuntu focal-updates/universe Translation-en [88.1 kB] Get:15 http://in.archive.ubuntu.com/ubuntu focal-updates/universe amd64 DEP-11 Metadata [186 kB] Get:16 http://in.archive.ubuntu.com/ubuntu focal-updates/universe DEP-11 48x48 Icons [93.4 kB] Get:17 http://in.archive.ubuntu.com/ubuntu focal-updates/universe DEP-11 64x64 Icons [167 kB] Get:18 http://in.archive.ubuntu.com/ubuntu focal-updates/universe amd64 c-n-f Metadata [5,580 B] install perl on ubuntu Get:19 http://in.archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 DEP-11 Metadata [2,468 B]install perl on ubuntu Get:20 http://in.archive.ubuntu.com/ubuntu focal-backports/universe amd64 DEP-11 Metadata [1,768 B]install perl on ubuntu Get:22 http://security.ubuntu.com/ubuntu focal-security/main i386 Packages [72.7 kB] Get:23 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [184 kB] Get:24 http://security.ubuntu.com/ubuntu focal-security/main Translation-en [65.5 kB] Get:25 http://security.ubuntu.com/ubuntu focal-security/main amd64 DEP-11 Metadata [24.3 kB] Get:26 http://security.ubuntu.com/ubuntu focal-security/main amd64 c-n-f Metadata [4,588 B] Get:27 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [58.8 kB] Get:28 http://security.ubuntu.com/ubuntu focal-security/universe i386 Packages [29.3 kB] Get:29 http://security.ubuntu.com/ubuntu focal-security/universe Translation-en [30.9 kB] Get:30 http://security.ubuntu.com/ubuntu focal-security/universe amd64 DEP-11 Metadata [52.4 kB] Get:31 http://security.ubuntu.com/ubuntu focal-security/universe amd64 c-n-f Metadata [2,476 B] Fetched 2,568 kB in 3s (951 kB/s) Reading package lists... Done
Step 3: Install Perl on Ubuntu 20.04
Once Server is updated you can now install the Perl package using apt install perl -y
command as shown below. This command will download and install the Perl package along with its dependencies from Ubuntu Repo as can be seen from below output.
root@localhost:~# apt install perl -y Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: apturl-common gir1.2-dbusmenu-glib-0.4 gir1.2-dee-1.0 gir1.2-goa-1.0 gir1.2-javascriptcoregtk-4.0 gir1.2-snapd-1 gir1.2-unity-5.0 gir1.2-webkit2-4.0 patch perl-openssl-defaults python3-dateutil python3-debconf python3-debian python3-software-properties sgml-base software-properties-common unattended-upgrades update-notifier-common xml-core Use 'apt autoremove' to remove them. Suggested packages: perl-doc libterm-readline-gnu-perl | libterm-readline-perl-install perl on ubuntu make libb-debug-perl liblocale-codes-perl The following NEW packages will be installed: perl 0 upgraded, 1 newly installed, 0 to remove and 88 not upgraded. Need to get 224 kB of archives. After this operation, 763 kB of additional disk space will be used. Get:1 http://in.archive.ubuntu.com/ubuntu focal/main amd64 perl amd64 5.30.0-9build1 [224 kB] Fetched 224 kB in 0s (760 kB/s) Selecting previously unselected package perl. (Reading database ... 160211 files and directories currently installed.) Preparing to unpack .../perl_5.30.0-9build1_amd64.deb ... Unpacking perl (5.30.0-9build1) ... Setting up perl (5.30.0-9build1) ... Processing triggers for man-db (2.9.1-1) ...
Step 4: Verify Your Package
After successful installation of Perl packages you can verify the installation by using apt list --installed | grep -i perl
command as shown below. You can check apt command Man Page to know more about the available options.
root@localhost:~# apt list --installed | grep -i perl WARNING: apt does not have a stable CLI interface. Use with caution in scripts. liblocale-gettext-perl/focal,now 1.07-4 amd64 [installed,automatic] libperl5.30/focal,now 5.30.0-9build1 amd64 [installed,automatic] libtext-charwidth-perl/focal,now 0.04-10 amd64 [installed,automatic] libtext-iconv-perl/focal,now 1.7-7 amd64 [installed,automatic] libtext-wrapi18n-perl/focal,focal,now 0.06-9 all [installed,automatic] perl-base/focal,now 5.30.0-9build1 amd64 [installed,automatic] perl-modules-5.30/focal,focal,now 5.30.0-9build1 all [installed,automatic] perl-openssl-defaults/focal,now 4 amd64 [installed,auto-removable] perl/focal,now 5.30.0-9build1 amd64 [installed]
Step 5: Check Perl Version
If you want to check the Perl version then you need to use perl -v
command as shown below. As shown in the below output, current perl version is v5.30.0
.
root@localhost:~# perl -v This is perl 5, version 30, subversion 0 (v5.30.0) built for x86_64-linux-gnu-thread-multi (with 46 registered patches, see perl -V for more detail) Copyright 1987-2019, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. Complete documentation for Perl, including FAQ lists, should be found on this system using "man perl" or "perldoc perl". If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page.
Step 6: Write Your First Perl Script
Now you are ready to write your first Perl Script. Here we are writing a simple perl script using vi
editor to display "Hi, this is from CyberITHub"
on the output.
root@localhost:~# vi example.pl #!/usr/bin/perl use warnings; print("Hi, this is from CyberITHub\n");
If you run the above script using perl example.pl
command then you will get below output. This confirms that Perl is successfully installed and working fine.
Output
root@localhost:~# perl example.pl Hi, this is from CyberITHub
Step 7: Install Perl Module on Ubuntu 20.04
If you want to install any Perl Module then you can use below apt install command. Here we are trying to install Perl MySQL module using apt install libdbd-mysql-perl -y
command as shown below.
root@localhost:~# apt install libdbd-mysql-perl -y Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: apturl-common gir1.2-dbusmenu-glib-0.4 gir1.2-dee-1.0 gir1.2-goa-1.0 gir1.2-javascriptcoregtk-4.0 gir1.2-snapd-1 gir1.2-unity-5.0 gir1.2-webkit2-4.0 patch perl-openssl-defaults python3-dateutil python3-debconf python3-debian python3-software-properties sgml-base software-properties-common unattended-upgrades update-notifier-common xml-core Use 'apt autoremove' to remove them. The following additional packages will be installed: libdbi-perl Suggested packages: libclone-perl libmldbm-perl libnet-daemon-perl libsql-statement-perl The following NEW packages will be installed: libdbd-mysql-perl libdbi-perl 0 upgraded, 2 newly installed, 0 to remove and 88 not upgraded. Need to get 813 kB of archives. After this operation, 2,432 kB of additional disk space will be used.
Recommended Posts:-
How to Install Let’s Encrypt(Certbot) on RHEL/CentOS 8 Using 10 Easy Steps
33 Practical Examples of ulimit command in Linux/Unix for Professionals
8 Easy Ways to check Ubuntu Version using Bash Command Line
5 Easy Steps to Install Openssh-Server on Ubuntu 20.04 to Enable SSH
Unix/Linux Find Files and Directories Owned By a Particular User(5 Useful Examples)
15 Practical Bash For Loop Examples in Linux/Unix for Professionals
6 Popular Methods to List All Running Services Under Systemd in Linux
How to Limit CPU Limit of a Process Using CPULimit in Linux (RHEL/CentOS 7/8)