Filters
How to search
  • Plain words find names, texts and examples.
  • "two words" finds the exact phrase.
  • --name or -x finds an option.
  • #word looks only inside commands.
  • @grep finds lessons and labs that use grep.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Put ! before a word to leave it out. OR between words means one of them.
  • ↑ ↓ to move · Enter to open · Esc to close · / to search

mc

The MinIO client: work with any S3-compatible object storage (MinIO, AWS S3, Azure via gateway, Ceph) — buckets, copies, mirrors, policies.

Level
DevSecOps service
Group
Databases and messaging
Needs root
No
Package
mcli
Also called
minio, mcli

What it does

MinIO is a fast S3-compatible object store you can run yourself (on VMs or Kubernetes) — useful for backups, Loki/Tempo storage, Terraform state in labs, and artifacts. mc works with aliases (a URL + keys) and has Unix-like commands: ls, cp, mirror, rm, cat, plus admin commands for users and policies. On some systems the binary is called mcli to avoid a clash with Midnight Commander.

How to write it

mc alias set NAME URL ACCESS_KEY SECRET_KEY
mc COMMAND ALIAS/BUCKET/PATH

Main parts

Commands

alias set|list|remove
Save server connections.
mb / rb ALIAS/BUCKET
Make / remove a bucket.
ls / tree / du
List / tree / size.
cp / mv / rm
Copy / move / remove objects.
mirror SRC DST
Sync folders or buckets (backups).
cat / head
Read an object.
share download PATH
Time-limited link.
version enable ALIAS/BUCKET
Turn on versioning.
ilm rule add
Lifecycle (expire old objects).
encrypt set sse-s3 ALIAS/BUCKET
Default encryption.
admin user|policy|info
Users, policies, server info.
anonymous set none ALIAS/BUCKET
No public access.

Options 6

Most used

Flags

--recursive, -r
Whole folder.
--remove
Delete extra files in the target (mirror).
--watch
Keep mirroring changes.
--older-than 30d
Filter by age (rm, ls).
--expire 1h
Link lifetime (share).
--json
JSON output.

Examples 10

$ run as a normal user# run as root (or with sudo)

  1. 1Run MinIO for a lab

    podman run -d --name minio -p 127.0.0.1:9000:9000 -p 127.0.0.1:9001:9001 -e MINIO_ROOT_USER=admin -e MINIO_ROOT_PASSWORD=labonly-2026 quay.io/minio/minio server /data --console-address :9001
  2. 2Set an alias and make a bucket

    mc alias set lab http://127.0.0.1:9000 admin labonly-2026
    mc mb lab/backups
    mc ls lab
  3. 3Copy and list files

    mc cp backup-2026-10-27.tar.gz.age lab/backups/web1/
    mc ls --recursive lab/backups/
  4. 4Mirror a folder every night (backup)

    mc mirror --overwrite /srv/backups lab/backups/web1
  5. 5Turn on versioning and default encryption

    mc version enable lab/backups
    mc encrypt set sse-s3 lab/backups
  6. 6Delete backups older than 30 days with a lifecycle rule

    mc ilm rule add --expire-days 30 lab/backups
  7. 7Make sure nothing is public

    mc anonymous get lab/backups
    mc anonymous set none lab/backups
  8. 8A user that can only write backups

    cat backup-writer.json
    {"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":["s3:PutObject","s3:ListBucket"],"Resource":["arn:aws:s3:::backups","arn:aws:s3:::backups/*"]}]}
    mc admin policy create lab backup-writer backup-writer.json
    mc admin user add lab web1-backup 'Ch4nge-me-2026-long'
    mc admin policy attach lab backup-writer --user web1-backup
  9. 9Share a file for one hour

    mc share download --expire 1h lab/backups/web1/backup-2026-10-27.tar.gz.age
  10. 10Use mc with AWS S3

    mc alias set s3 https://s3.eu-central-1.amazonaws.com AKIAEXAMPLEONLY0000 exampleSecretOnly
    mc ls s3/s0sta-lab-backups-2026

Watch out

  • Aliases store keys in ~/.mc/config.json — keep it private.
  • mirror --remove deletes objects in the target that are not in the source.
  • Backup users should not have delete rights (protects against ransomware); use versioning or object lock.

Files

~/.mc/config.json
Aliases and keys.

Tips to remember

  • Use object lock (WORM) for backups that even an admin cannot delete for N days.

Exit codes

0Success.
1Error.