SkillByAIOpen interactive version →

Lesson 3 / 20

redis-cli Basics

Use redis-cli interactively and in scripts to connect to local or remote servers and run commands.

Connecting

Run without arguments for an interactive prompt, or connect to a remote host and port directly.

redis-cli
127.0.0.1:6379> SET greeting "hello"
OK
127.0.0.1:6379> GET greeting
"hello"

# or connect elsewhere
redis-cli -h cache.example.com -p 6379 --user app --askpass

One-shot commands

You don't need the interactive prompt for scripting — pass the command as arguments: redis-cli SET k v, handy inside shell scripts.

Quick check: What does a healthy Redis server reply to `PING`?

  • OK
  • ALIVE
  • PONG
  • ERROR
Answer

PONG — `PING` is the standard liveness check and always returns `PONG`.