# redis-cli Basics — Redis Fundamentals: Caching, Data Structures and Persistence

Source: https://www.skillbyai.com/en/redis/redis-cli

> 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.

```bash
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.

**Quiz:** What does a healthy Redis server reply to `PING`?

- [ ] OK
- [ ] ALIVE
- [x] PONG
- [ ] ERROR

*Answer:* PONG. `PING` is the standard liveness check and always returns `PONG`.
