mihomo-cli
English | 简体中文
A command-line, Clash-style proxy client for Linux machines without a desktop, powered by the mihomo core. Use it through an interactive menu or plain commands.
- Proxy services: an airport subscription, a local Clash/mihomo file, or hand-added node links (e.g. your own VPS)
- Switch nodes without restarting; latency test and automatic fastest-node pick
- Global / rule / direct modes, plus a switch for whether domestic (CN) sites go direct
- Background systemd service, installed with a single
sudo; no root needed day to day - Optional TUN mode for the whole machine, including programs that ignore proxy settings
- Every change is validated, backed up, and rolled back automatically if it fails
doctorself-check with fixes,--jsonoutput, English / Chinese interface, shell completion
Supported: Linux (tested on Ubuntu 20.04 / 22.04 / 24.04), Python 3.8+. macOS and Windows are not supported yet.
Install
If pipx is not installed yet, install it first, then open a new terminal so ~/.local/bin is on PATH:
sudo apt update && sudo apt install -y pipx python3-venv
pipx ensurepath
pipx install mihomo-cli
mihomo-cli install # downloads the mihomo core and geo data, installs the service (asks for sudo once)
If GitHub is slow to reach, pass a mirror that proxies https://github.com:
mihomo-cli install --mirror https://your-mirror.example/https://github.com
Quick start
mihomo-cli profile add airport --url 'https://example.com/sub?token=...'
# or a single self-hosted node
mihomo-cli profile add vps --node 'vless://...#my-vps'
mihomo-cli node auto # pick the fastest node
mihomo-cli status # one-screen overview including exit IP
eval "$(mihomo-cli proxy-env on)" # proxy the current shell (127.0.0.1:7897)
Run mihomo-cli with no arguments to open the menu. mihomo-cli help <command> shows help and examples.
Commands
| Command | What it does |
|---|---|
status |
Service, core, proxy service, node, mode, CN switch, TUN, port, exit IP |
install / uninstall |
Install or remove the core and the systemd service |
core upgrade |
Replace the core; the old one is kept if verification fails |
service start/stop/restart/status/logs |
Control the background service |
profile list/show/add/rm/use/update/rename |
Manage proxy services |
node list/use/add/rm/restore/test/auto |
Manage nodes of the active proxy service |
mode [global/rule/direct] |
Show or set the mode |
cn [direct/proxy] |
Domestic sites direct or via proxy (rule mode) |
tun on/off/status |
Whole-machine TUN mode (on/off need sudo) |
proxy-env [on/off] |
Print shell statements for proxy variables |
conns / logs |
Active connections and core logs |
backup list/restore |
Automatic backups (latest 10) |
doctor [--fix] |
15 checks with fix hints |
completion bash/zsh [--install] |
Shell completion and the mproxy on/off helper |
Global options: --json, --lang zh|en, --home DIR (or MIHOMO_CLI_HOME), --version.
Exit codes: 0 ok, 1 error, 2 usage, 3 core unreachable, 4 invalid config or rolled back, 5 needs sudo or run as root, 6 unsupported platform, 7 rollback incomplete (manual action needed).
Files
Everything lives in ~/.local/share/mihomo-cli (mode 0700): state.yaml (what you asked for — the
source of truth), the generated config.yaml, the core in bin/, backups/, and mihomo-cli.log.
The service unit is /etc/systemd/system/mihomo-cli.service.
Notes
- The mihomo core (GPL-3.0) is not bundled; it is downloaded from the official releases and checked against the published SHA-256 digest when available.
- mihomo-cli runs as its own instance and does not touch other mihomo / Clash services. Only one TUN can
be active on a machine;
tun onrefuses if another one is running. - Do not run mihomo-cli with
sudo; it calls sudo itself for the few steps that need it.
License
MIT
Metadata
Release files for mihomo-cli 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| mihomo_cli-0.1.1.tar.gz | 89.6 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mihomo_cli-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 172.6 kB
Release files / mihomo_cli-0.1.1.tar.gz
| Download URL | mihomo_cli-0.1.1.tar.gz |
|---|---|
| Size | 89.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9733ac8b7b3f2429f8ca1cf5103c3e17add8e68199a405b7611204fa0b19c980
|
|
BLAKE2b-256 checksum How to use checksums |
6b2c851fc0d831aecbe77fad43deed43e0bb6cf23abf56d81d6a488afcfc525e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logRelease files / mihomo_cli-0.1.1-py3-none-any.whl
| Download URL | mihomo_cli-0.1.1-py3-none-any.whl |
|---|---|
| Size | 82.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8d5107106b9ababcfc1599efbd6e91de0e1c2ee9487d75455acbdb1036336679
|
|
BLAKE2b-256 checksum How to use checksums |
1a54adeb0d1e03ea1d00f82d51dca6f6dc4e6f0272eaa941b077ca5b39eef0a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logSecurity for mihomo-cli 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for mihomo_cli-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.