Redis operates as an in-memory data structure store. It functions as a database, cache, and message broker. The command-line interface provides direct access to Redis servers. Install the CLI tool separately when full server deployment is unnecessary.

Understanding Redis CLI

Redis CLI connects to Redis instances and executes commands. Run queries, manage keys, and monitor server performance through this utility. The tool supports interactive mode for ongoing sessions and command mode for single operations.

Two primary modes exist:

  • Interactive mode launches a persistent session for multiple commands
  • Command mode executes single operations and exits

Why Install Redis CLI Only

Full Redis installations require extensive dependencies. Compilers, build tools, and configuration files consume system resources. Avoid these requirements when connecting to remote servers.

Factor Benefit
Resource Usage Minimal disk and memory footprint
Installation Speed Faster deployment on client machines
Dependencies No compiler or build requirements
Maintenance Simpler update process

Development teams working with cloud-hosted Redis benefit most from CLI-only setups. Skip server administration when databases run elsewhere.

Using the redis-tools Package

Debian and Ubuntu distributions provide redis-tools. This package contains client utilities without server components.

Update package lists and install:

$ sudo apt update
$ sudo apt install redis-tools

Connect to remote instances:

$ redis-cli -h hostname -p port

Replace hostname with your server address. Default port is 6379.

Note: The redis-tools package works only on Debian-based systems like Ubuntu and Linux Mint.

Installing via Node.js

Node.js offers cross-platform Redis CLI installation. This method works on Linux, Windows, and macOS.

Install Node.js and npm first. Execute this command:

$ npm install -g redis-cli

Launch the client using rdcli:

$ rdcli -h server.address -p 6379 -a password
Platform Support Level
Linux Full support
Windows Full support
macOS Full support
Tip: Add redis-cli to your project’s devDependencies to ensure team members have consistent tooling.

Building From Source

Compile Redis CLI from official source code. This approach provides maximum control and works across all distributions.

Install build dependencies:

$ sudo yum install gcc openssl-devel

Download and extract source:

$ wget http://download.redis.io/redis-stable.tar.gz
$ tar xvzf redis-stable.tar.gz
$ cd redis-stable

Build only the CLI:

$ make distclean
$ make redis-cli BUILD_TLS=yes

Install to system path:

$ sudo install -m 755 src/redis-cli /usr/local/bin/
Note: The BUILD_TLS=yes flag enables TLS support for secure connections to Redis servers.

TLS Support

Enable encrypted connections by including TLS during compilation. Install openssl-devel before building.

Connect using TLS:

$ redis-cli -h hostname -p 6379 --tls

Docker Container Approach

Docker provides isolated Redis CLI environments. Alpine-based images offer minimal size.

Run CLI without installation:

$ docker run -it --rm redis:latest-alpine redis-cli -h redis.server.com -p 6379

This command pulls the image, launches the CLI, and removes the container after exit.

Custom Docker Images

Build customized CLI images using Dockerfiles:

FROM alpine:latest
RUN apk add --no-cache redis
ENTRYPOINT ["redis-cli"]

Build and tag the image:

$ docker build -t custom-redis-cli .
$ docker run -it custom-redis-cli -h hostname
Tip: Alpine images reduce download size significantly compared to full Linux distributions.

Package Manager Options

Different distributions offer varying package names. Red Hat systems use EPEL repositories.

Red Hat and CentOS

Enable EPEL repository:

$ sudo yum install epel-release
$ sudo yum install redis

Amazon Linux

Use Amazon Linux Extras:

$ sudo amazon-linux-extras enable redis6
$ sudo yum clean metadata
$ sudo yum install redis
Warning: Package versions may lag behind upstream releases. Verify version compatibility before installation.

Verification and Testing

Confirm installation success by checking version:

$ redis-cli --version

Test server connectivity:

$ redis-cli -h hostname ping

Successful connection returns PONG.

FAQs

Yes. Use the redis-tools package on Debian systems, compile from source, or install via Node.js for CLI-only access.

Install Node.js and run npm install -g redis-cli. Alternatively, use Docker or Windows Subsystem for Linux.

Yes. Build from source with BUILD_TLS=yes flag, then connect using the –tls option for encrypted communication.

The redis-tools package on Debian systems installs fastest. Docker containers provide quick deployment without system modifications.

Yes. Specify hostname with -h flag and port with -p flag. Use -a for authentication when required.

Willie has over 15 years of experience in Linux system administration and DevOps. After managing infrastructure for startups and enterprises alike, he founded Command Linux to share the practical knowledge he wished he had when starting out. He oversees content strategy and contributes guides on server management, automation, and security.