Install Redis on Ubuntu 24.04

Install Redis on Ubuntu 24.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 24.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:

redis-cli

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

127.0.0.1:6379> PING
PONG

SET and GET commands can be used to store and retrieve value by key.

127.0.0.1:6379> SET message "Hello"
OK
127.0.0.1:6379> GET message
"Hello"

Type QUIT command to exit the Redis prompt.

127.0.0.1:6379> QUIT

Uninstall Redis

Disable Redis service:

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

Remove Redis by using the following command:

sudo apt purge --autoremove -y redis

Remove repository:

sudo rm -rf /etc/apt/sources.list.d/redislabs-ubuntu-redis-noble.sources

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.