Install Redis on Ubuntu 22.04

Install Redis on Ubuntu 22.04

Redis is an in-memory key-value data structure store. It often used as a database, cache, and message broker. Redis is an open-source project which released under a 3-clause BSD license.

This tutorial demonstrates how to install Redis on Ubuntu 22.04.

Install Redis

Add the official Redis repository:

sudo add-apt-repository -y ppa:redislabs/redis

Install Redis:

sudo apt install -y redis

Once installation is completed, we can check Redis version:

redis-server --version

Execute the following command to enable Redis to start on boot:

sudo systemctl enable redis-server

You can check whether Redis service is running with command:

sudo service redis-server status

We can also stop, start and restart the Redis service:

sudo service redis-server stop
sudo service redis-server start
sudo service redis-server restart

Testing Redis

Connect to the Redis server with client:


For connectivity testing, use PING command. Server returns PONG.> PING

SET and GET commands can be used to store and retrieve value by key.> SET message "Hello"
OK> GET message

Type QUIT command to exit the Redis prompt.> QUIT

Uninstall Redis

If you decided to completely remove Redis, run the following command:

sudo apt purge --autoremove -y redis

Disable Redis service:

sudo systemctl disable redis-server
sudo systemctl daemon-reload
sudo systemctl reset-failed

Remove GPG key and repository:

sudo rm -rf /etc/apt/trusted.gpg.d/redislabs-ubuntu-redis.gpg*
sudo rm -rf /etc/apt/sources.list.d/redislabs-ubuntu-redis-jammy.list

You can also remove a history of commands executed with Redis client:

rm -rf ~/.rediscli_history

Leave a Comment

Cancel reply

Your email address will not be published.