How To Install Redis CLI on Ubuntu

In this tutorial, we learn how to install Redis CLI on Ubuntu. This tutorial can be used in any version of Ubuntu including but not limited to Ubuntu 20.04/18.04/16.04.

Introduction

In this tutorial, we learn how to install Redis CLI on Ubuntu. This tutorial can be used in any version of Ubuntu including but not limited to Ubuntu 20.04/18.04/16.04.

Install Redis CLI from Ubuntu Repository

We can install redis-cli from Ubuntu repository using the following commands.

First, we need to update the Ubuntu apt database using the command below

sudo apt update

As alternative command to update apt database, you can also run the command below

sudo apt-get update

After updating apt database we can install redis-cli using the command below:

sudo apt install redis-tools

Install Redis CLI from PPA Repository

In the previous step, we learned how to install redis-cli from the Ubuntu repository. If you need a newer version of redis-cli you can install a newer redis-tools package from the PPA repository.

First let’s add the PPA repository using the command below:

sudo add-apt-repository ppa:redislabs/redis

Next step is to update apt metadata using the command below:

sudo apt update

We can also use apt-get command to update apt metadata using the command below:

sudo apt-get update

After updating apt database we can install Redis CLI using the command below:

sudo apt-get install redis-tools

As alternative, we can also use apt command to install Redis CLI using the command below:

sudo apt install redis-tools

To use redis cli we can use the command below

redis-cli -h <redis-server> -p <redis-port> 

Replace <redis-server> with the hostname or IP address of your redis server and <redis-port> with the redis port. Redis default port is 6379.

Video Tutorial

Summary

In this tutorial we learn how to install Redis CLI from Ubuntu repository and redislabs team PPA repository.

Installing redis-cli might be necessary when you need to connect to a remote redis instance without having to install the redis server package. Until next time.