How To Install cpanminus on Ubuntu 20.04

In this tutorial we learn how to install cpanminus on Ubuntu 20.04. cpanminus is script to get, unpack, build and install modules from CPAN

Introduction

In this tutorial we learn how to install cpanminus on Ubuntu 20.04.

What is cpanminus

cpanminus is:

cpanminus provides a command-line (non interactive) interface to automatically download, build and install Perl modules from CPAN.

It requires zero configuration, and stands alone. It also has a very low memory footprint compared to similar software: when running, it requires only 10MB of RAM.

It installs to wherever ExtUtils::MakeMaker and Module::Build are configured to. So if you’re using local::lib, then it installs to your local perl5 directory. Otherwise it installs to the siteperl directory.

cpanminus at a boot time checks whether you have configured local::lib, or have the permission to install modules to the sitelib directory. If neither, it automatically sets up local::lib compatible installation path in a perl5 directory under your home directory.

There are three methods to install cpanminus on Ubuntu 20.04. We can use apt-get, apt and aptitude. In the following sections we will describe each method. You can choose one of them.

Install cpanminus Using apt-get

Update apt database with apt-get using the following command.

sudo apt-get update

After updating apt database, We can install cpanminus using apt-get by running the following command:

sudo apt-get -y install cpanminus

Install cpanminus Using apt

Update apt database with apt using the following command.

sudo apt update

After updating apt database, We can install cpanminus using apt by running the following command:

sudo apt -y install cpanminus

Install cpanminus Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Ubuntu. Update apt database with aptitude using the following command.

sudo aptitude update

After updating apt database, We can install cpanminus using aptitude by running the following command:

sudo aptitude -y install cpanminus

How To Uninstall cpanminus on Ubuntu 20.04

To uninstall only the cpanminus package we can use the following command:

sudo apt-get remove cpanminus

Uninstall cpanminus And Its Dependencies

To uninstall cpanminus and its dependencies that are no longer needed by Ubuntu 20.04, we can use the command below:

sudo apt-get -y autoremove cpanminus

Remove cpanminus Configurations and Data

To remove cpanminus configuration and data from Ubuntu 20.04 we can use the following command:

sudo apt-get -y purge cpanminus

Remove cpanminus configuration, data, and all of its dependencies

We can use the following command to remove cpanminus configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge cpanminus

References

Summary

In this tutorial we learn how to install cpanminus package on Ubuntu 20.04 using different package management tools: apt, apt-get and aptitude.