How To Install grep on Debian 9

In this tutorial we learn how to install grep on Debian 9. grep is GNU grep, egrep and fgrep

Introduction

In this tutorial we learn how to install grep on Debian 9.

What is grep

grep is:

‘grep’ is a utility to search for text in files; it can be used from the command line or in scripts. Even if you don’t want to use it, other packages on your system probably will.

The GNU family of grep utilities may be the “fastest grep in the west”. GNU grep is based on a fast lazy-state deterministic matcher (about twice as fast as stock Unix egrep) hybridized with a Boyer-Moore-Gosper search for a fixed string that eliminates impossible text from being considered by the full regexp matcher without necessarily having to look at every character. The result is typically many times faster than Unix grep or egrep. (Regular expressions containing backreferencing will run more slowly, however.)

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

Install grep Using apt-get

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

sudo apt-get update

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

sudo apt-get -y install grep

Install grep Using apt

Update apt database with apt using the following command.

sudo apt update

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

sudo apt -y install grep

Install grep 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 Debian. Update apt database with aptitude using the following command.

sudo aptitude update

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

sudo aptitude -y install grep

How To Uninstall grep on Debian 9

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

sudo apt-get remove grep

Uninstall grep And Its Dependencies

To uninstall grep and its dependencies that are no longer needed by Debian 9, we can use the command below:

sudo apt-get -y autoremove grep

Remove grep Configurations and Data

To remove grep configuration and data from Debian 9 we can use the following command:

sudo apt-get -y purge grep

Remove grep configuration, data, and all of its dependencies

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

sudo apt-get -y autoremove --purge grep

Dependencies

grep have the following dependencies:

References

Summary

In this tutorial we learn how to install grep package on Debian 9 using different package management tools: apt, apt-get and aptitude.