> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.bitiful.com/en/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.bitiful.com/_mcp/server.

# Use the MinIO CLI (mc)

> Connect to Bitiful S4 with MinIO Client (mc): aliases, upload and download, syncing and watching directories, finding files, share links, and tags.

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.

> **Warning**
>
> 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](https://docs.bitiful.com/en/clients/aws-cli.md), or [Rclone](https://docs.bitiful.com/en/clients/rclone.md).

## Prerequisites

- You have [created a bucket](https://docs.bitiful.com/en/bitiful-s4/handbook/buckets.md);
- You have [created a sub-user and AccessKey](https://docs.bitiful.com/en/bitiful-s4/handbook/access-keys.md) and completed the [grants](https://docs.bitiful.com/en/bitiful-s4/handbook/permissions.md).

## Install

**Windows**

Install [Go](https://go.dev/dl/), then run:

```powershell title="PowerShell"
go install github.com/minio/mc@latest
```

**macOS**

```bash
brew install minio-mc
```

**Linux**

Install [Go](https://go.dev/dl/), then run:

```bash
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](https://github.com/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

**Windows**

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

**macOS**

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

**Linux**

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

**Windows**

```powershell title="PowerShell"
mc.exe ls s4
mc.exe ls s4/my-bucket/
```

**macOS**

```bash
mc ls s4
mc ls s4/my-bucket/
```

**Linux**

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

**Windows**

```powershell title="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
```

**macOS**

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

**Linux**

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

**Windows**

```powershell title="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
```

**macOS**

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

**Linux**

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

> **Warning**
>
> `--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

**Windows**

```powershell title="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
```

**macOS**

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

**Linux**

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

**Windows**

```powershell title="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
```

**macOS**

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

**Linux**

```bash
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](https://docs.bitiful.com/en/bitiful-s4/features/move-object.md).

## Share links

**Windows**

```powershell title="PowerShell"
mc.exe share download --expire 1h s4/my-bucket/images/logo.png
```

**macOS**

```bash
mc share download --expire 1h s4/my-bucket/images/logo.png
```

**Linux**

```bash
mc share download --expire 1h s4/my-bucket/images/logo.png
```

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

## Tags

**Windows**

```powershell title="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
```

**macOS**

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

**Linux**

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

**Windows**

```powershell title="PowerShell"
mc.exe ls --incomplete s4/my-bucket/
mc.exe rm -r --force --incomplete s4/my-bucket/
```

**macOS**

```bash
mc ls --incomplete s4/my-bucket/
mc rm -r --force --incomplete s4/my-bucket/
```

**Linux**

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

**Windows**

```powershell title="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
```

**macOS**

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

**Linux**

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

| Need                 | Where in the console                                                                      |
| -------------------- | ----------------------------------------------------------------------------------------- |
| Public read          | [Public read and private](https://docs.bitiful.com/en/bitiful-s4/handbook/public-read.md) |
| Sub-users and grants | [Sub-user permissions](https://docs.bitiful.com/en/bitiful-s4/handbook/permissions.md)    |
| Cross-origin access  | [CORS settings](https://docs.bitiful.com/en/bitiful-s4/handbook/cors.md)                  |

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

## FAQ

<details>
<summary>The request signature we calculated does not match</summary>

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

</details>

<details>
<summary>mc ls s4 returns nothing</summary>

It only lists buckets the sub-user has been granted access to. [Grant access](https://docs.bitiful.com/en/bitiful-s4/handbook/permissions.md) first.

</details>

<details>
<summary>Access Denied</summary>

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

</details>

<details>
<summary>mc opens a blue file manager</summary>

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

</details>
