Use Redis on a Linux server to implement a fast, in-memory key-value data store that supports a wide variety of data structures and use cases such as caching, real-time analytics, session management, and messaging. Redis offers excellent performance, flexibility, and reliability, making it one of the most popular NoSQL databases today.
It supports persistence, replication, and high availability through Redis Sentinel and clustering. Its lightweight footprint and rich feature set make it ideal for both small-scale deployments and large-scale enterprise systems.

This guide will take you through installing and using Redis on a Linux server, starting and enabling the Redis service, basic configuration, and testing to get you started confidently.
Prerequisites
- A Linux server running supported distributions like Ubuntu, Debian, CentOS, Rocky Linux, or Red Hat
- Root or sudo privileges to install and manage services
- Terminal access for command execution
Use Redis on Linux
Redis is a fast, open-source in-memory data store used as a database, cache, and message broker. Using Redis on a Linux server ensures low-latency performance, high availability, and seamless integration with web applications and microservices.
Install Redis on the Linux Server
Begin by installing Redis using your Linux distribution’s package manager. This ensures you get the latest stable version along with dependencies, making setup quick and reliable.
- On Ubuntu/Debian
Redis provides an official repository to install the latest stable version. To install Redis, run these commands in your terminal:
sudo apt-get install lsb-release curl gpg
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
sudo chmod 644 /usr/share/keyrings/redis-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
sudo apt-get update
sudo apt-get install redis
- On CentOS/Red Hat/Rocky Linux
Simply install Redis from the default repositories using:
sudo yum install redis
or on newer systems with dnf
:
sudo dnf install redis
Start and Enable the Redis Service
After installing Redis, start the Redis server and enable it to start automatically at boot:
sudo systemctl start redis-server # On Ubuntu/Debian
sudo systemctl enable redis-server
sudo systemctl start redis # On CentOS/RHEL/Rocky Linux
sudo systemctl enable redis
Check the status to confirm Redis is running:
sudo systemctl status redis-server # Ubuntu/Debian
sudo systemctl status redis # CentOS/RHEL/Rocky Linux
Configure Redis on Linux
You can configure Redis by editing its main configuration file, usually located at:
/etc/redis/redis.conf
(Ubuntu/Debian)/etc/redis.conf
or/etc/redis/redis.conf
(CentOS/RHEL)
Common configuration options include:
- Bind address: By default, Redis listens on localhost (
127.0.0.1
). To allow external connections (requires caution), update thebind
directive. - Protected mode: Enable or disable protected mode to restrict unsafe connections.
- Requirepass: Set a password to require authentication.
- Save intervals: Configure how frequently Redis saves snapshots to disk.
After making changes, restart Redis to apply settings:
sudo systemctl restart redis-server # Ubuntu/Debian
sudo systemctl restart redis # CentOS/RHEL/Rocky Linux
Check Out | Learn How to Configure MongoDB on Linux: A Step-by-Step Guide
Test Redis Installation
Test that Redis is working properly by using the Redis CLI client:
redis-cli
In the Redis interactive prompt, type:
ping
If Redis is running correctly, you should receive:
PONG
Exit the CLI with:
exit
Basic Redis Commands
Here are some simple commands to try in the Redis CLI:
- Set a key:
set mykey "Hello Redis"
- Get the value of a key:
get mykey
- Increment a numeric key:
incr mycounter
- Delete a key:
del mykey
Check Out | Understand Redis on Linux: What You Should Know
Conclusion
To use Redis on a Linux server, install Redis from official repositories or package managers, start and enable the Redis service, optionally customize the configuration, and use redis-cli
to interact with your server. Redis offers powerful data structures and blazing-fast performance for caching, session management, and real-time data processing. For advanced setup, clustering, security hardening, and scripting, refer to the official Redis documentation.