Skip to content

Use the MinIO CLI (mc)

MinIO Client (mc) is a command-line tool that works like the Unix commands ls, cp, and find, and connects to any S3-compatible object storage.

MinIO no longer maintains mc: its website no longer offers downloads, and there are no more security updates. If you already use it, you can continue; the commands here were tested with the last version. For new projects, we recommend AWS CLI, s5cmd, or Rclone.

Prerequisites

Install

Install Go, then run:

PowerShell
go install github.com/minio/mc@latest
brew install minio-mc

Install Go, then run:

go install github.com/minio/mc@latest

On Windows, run the commands in PowerShell and replace D:\ in the examples with your own directory.

Homebrew has deprecated it and plans to disable it in July 2027. For a community-maintained fork, see pgsty/mc. Its program is named mcli, and the commands are the same.

If Midnight Commander is installed on Linux, its program is also named mc. Rename one of them.

Configure

PowerShell
mc.exe alias set s4 https://s3.bitiful.net "Your AccessKey" "Your SecretKey" --api S3v4
mc alias set s4 https://s3.bitiful.net "Your AccessKey" "Your SecretKey" --api S3v4
mc alias set s4 https://s3.bitiful.net "Your AccessKey" "Your SecretKey" --api S3v4

After that, s4/bucket/path refers to a location in S4. Verify:

PowerShell
mc.exe ls s4
mc.exe ls s4/my-bucket/
mc ls s4
mc ls s4/my-bucket/
mc ls s4
mc ls s4/my-bucket/

Keys are stored unencrypted in ~/.mc/config.json (C:\Users\username\mc\config.json on Windows), so mind the file permissions.

Upload and download

PowerShell
# Upload a file or directory
mc.exe cp D:\logo.png s4/my-bucket/images/logo.png
mc.exe cp -r D:\dist\ s4/my-bucket/site/

# Specify the type, cache, and custom metadata, separated by semicolons
mc.exe cp --attr "Cache-Control=max-age=86400;Content-Type=text/css;owner=web" D:\app.css s4/my-bucket/static/app.css

# Back up a database and upload it
mysqldump.exe mydb --result-file=D:\backup\mydb.sql
mc.exe cp D:\backup\mydb.sql s4/my-bucket/backup/mydb.sql

# Download
mc.exe cp s4/my-bucket/images/logo.png D:\
mc.exe get s4/my-bucket/images/logo.png D:\logo.png
# Upload a file or directory
mc cp ./logo.png s4/my-bucket/images/logo.png
mc cp -r ./dist/ s4/my-bucket/site/

# Specify the type, cache, and custom metadata, separated by semicolons
mc cp --attr "Cache-Control=max-age=86400;Content-Type=text/css;owner=web" ./app.css s4/my-bucket/static/app.css

# Upload from standard input
mysqldump mydb | gzip | mc pipe s4/my-bucket/backup/mydb.sql.gz

# Download
mc cp s4/my-bucket/images/logo.png ./
mc get s4/my-bucket/images/logo.png ./logo.png
# Upload a file or directory
mc cp ./logo.png s4/my-bucket/images/logo.png
mc cp -r ./dist/ s4/my-bucket/site/

# Specify the type, cache, and custom metadata, separated by semicolons
mc cp --attr "Cache-Control=max-age=86400;Content-Type=text/css;owner=web" ./app.css s4/my-bucket/static/app.css

# Upload from standard input
mysqldump mydb | gzip | mc pipe s4/my-bucket/backup/mydb.sql.gz

# Download
mc cp s4/my-bucket/images/logo.png ./
mc get s4/my-bucket/images/logo.png ./logo.png

Large files are uploaded in parts automatically.

Sync directories

PowerShell
# Dry run first
mc.exe mirror --dry-run --overwrite --remove D:\dist s4/my-bucket/site

# Make the destination match the local directory; --remove deletes extra files in the destination
mc.exe mirror --overwrite --remove D:\dist s4/my-bucket/site

# Download a whole directory
mc.exe mirror s4/my-bucket/site D:\site

# Watch a local directory and upload changes
mc.exe mirror --watch D:\uploads s4/my-bucket/uploads
# Dry run first
mc mirror --dry-run --overwrite --remove ./dist s4/my-bucket/site

# Make the destination match the local directory; --remove deletes extra files in the destination
mc mirror --overwrite --remove ./dist s4/my-bucket/site

# Download a whole directory
mc mirror s4/my-bucket/site ./site

# Watch a local directory and upload changes
mc mirror --watch ./uploads s4/my-bucket/uploads
# Dry run first
mc mirror --dry-run --overwrite --remove ./dist s4/my-bucket/site

# Make the destination match the local directory; --remove deletes extra files in the destination
mc mirror --overwrite --remove ./dist s4/my-bucket/site

# Download a whole directory
mc mirror s4/my-bucket/site ./site

# Watch a local directory and upload changes
mc mirror --watch ./uploads s4/my-bucket/uploads

--remove deletes files in the destination that are not in the source, and S4 has no recycle bin. Do a dry run with --dry-run first.

View and find

PowerShell
mc.exe ls -r s4/my-bucket/images/                                # List recursively
mc.exe du s4/my-bucket/images                                    # Calculate size
mc.exe stat s4/my-bucket/images/logo.png                         # Metadata
mc.exe cat s4/my-bucket/notes/todo.txt                           # View contents
mc.exe head -n 20 s4/my-bucket/logs/app.log                      # First 20 lines
mc.exe diff D:\dist s4/my-bucket/site                            # Compare local files with the bucket

mc.exe find s4/my-bucket --name "*.mp4"                          # By name
mc.exe find s4/my-bucket --older-than 30d --larger 100MB         # By age and size
mc ls -r s4/my-bucket/images/                                # List recursively
mc du s4/my-bucket/images                                    # Calculate size
mc stat s4/my-bucket/images/logo.png                         # Metadata
mc cat s4/my-bucket/notes/todo.txt                           # View contents
mc head -n 20 s4/my-bucket/logs/app.log                      # First 20 lines
mc diff ./dist s4/my-bucket/site                             # Compare local files with the bucket

mc find s4/my-bucket --name "*.mp4"                          # By name
mc find s4/my-bucket --older-than 30d --larger 100MB         # By age and size
mc ls -r s4/my-bucket/images/                                # List recursively
mc du s4/my-bucket/images                                    # Calculate size
mc stat s4/my-bucket/images/logo.png                         # Metadata
mc cat s4/my-bucket/notes/todo.txt                           # View contents
mc head -n 20 s4/my-bucket/logs/app.log                      # First 20 lines
mc diff ./dist s4/my-bucket/site                             # Compare local files with the bucket

mc find s4/my-bucket --name "*.mp4"                          # By name
mc find s4/my-bucket --older-than 30d --larger 100MB         # By age and size

Move and delete

PowerShell
mc.exe mv s4/my-bucket/a.txt s4/my-bucket/b.txt

mc.exe rm s4/my-bucket/a.txt
mc.exe rm -r --force s4/my-bucket/tmp/                           # Delete a whole directory, cannot be undone
mc.exe rm -r --force --older-than 30d s4/my-bucket/logs/         # Only files older than 30 days
mc mv s4/my-bucket/a.txt s4/my-bucket/b.txt

mc rm s4/my-bucket/a.txt
mc rm -r --force s4/my-bucket/tmp/                           # Delete a whole directory, cannot be undone
mc rm -r --force --older-than 30d s4/my-bucket/logs/         # Only files older than 30 days
mc mv s4/my-bucket/a.txt s4/my-bucket/b.txt

mc rm s4/my-bucket/a.txt
mc rm -r --force s4/my-bucket/tmp/                           # Delete a whole directory, cannot be undone
mc rm -r --force --older-than 30d s4/my-bucket/logs/         # Only files older than 30 days

mc mv copies and then deletes. For large files, use S4's native move.

PowerShell
mc.exe share download --expire 1h s4/my-bucket/images/logo.png
mc share download --expire 1h s4/my-bucket/images/logo.png
mc share download --expire 1h s4/my-bucket/images/logo.png

The link is valid for up to 7 days (168h).

Tags

PowerShell
mc.exe tag set s4/my-bucket/images/logo.png "env=prod&team=web"
mc.exe tag list s4/my-bucket/images/logo.png
mc tag set s4/my-bucket/images/logo.png "env=prod&team=web"
mc tag list s4/my-bucket/images/logo.png
mc tag set s4/my-bucket/images/logo.png "env=prod&team=web"
mc tag list s4/my-bucket/images/logo.png

Incomplete multipart uploads

PowerShell
mc.exe ls --incomplete s4/my-bucket/
mc.exe rm -r --force --incomplete s4/my-bucket/
mc ls --incomplete s4/my-bucket/
mc rm -r --force --incomplete s4/my-bucket/
mc ls --incomplete s4/my-bucket/
mc rm -r --force --incomplete s4/my-bucket/

Copy between two storage services

Set an alias for the other storage service to copy directly:

PowerShell
mc.exe alias set old https://oss-cn-hangzhou.aliyuncs.com "Source AccessKey" "Source SecretKey"
mc.exe mirror old/old-bucket s4/my-bucket
mc alias set old https://oss-cn-hangzhou.aliyuncs.com "Source AccessKey" "Source SecretKey"
mc mirror old/old-bucket s4/my-bucket
mc alias set old https://oss-cn-hangzhou.aliyuncs.com "Source AccessKey" "Source SecretKey"
mc mirror old/old-bucket s4/my-bucket

The data passes through the machine running mc.

Commands that do not apply

Commands such as mc admin, mc anonymous set, mc ilm, mc replicate, mc version enable, and mc encrypt manage a MinIO server or depend on features S4 does not provide. Use the console for these settings:

NeedWhere in the console
Public readPublic read and private
Sub-users and grantsSub-user permissions
Cross-origin accessCORS settings

Sub-users cannot create buckets, and mc mb returns a permission error.

FAQ

The request signature we calculated does not match

Check whether the keys have extra spaces and whether the local clock is accurate. Quote keys that contain special characters.

mc ls s4 returns nothing

It only lists buckets the sub-user has been granted access to. Grant access first.

Access Denied

If only a directory is granted, point the path to that directory, for example s4/my-bucket/images/.

mc opens a blue file manager

That is Midnight Commander. Use the full path instead, for example ~/go/bin/mc.