{"id":26512060,"url":"https://github.com/nelvko/clash-for-linux-install","last_synced_at":"2025-05-14T22:09:20.579Z","repository":{"id":227139457,"uuid":"770579617","full_name":"nelvko/clash-for-linux-install","owner":"nelvko","description":"😼 优雅地部署基于 clash/mihomo 的代理环境","archived":false,"fork":false,"pushed_at":"2025-05-06T06:41:50.000Z","size":95359,"stargazers_count":1421,"open_issues_count":9,"forks_count":242,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-06T07:51:02.705Z","etag":null,"topics":["clash","linux","mihomo","subconverter"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nelvko.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-03-11T19:46:13.000Z","updated_at":"2025-05-06T07:27:45.000Z","dependencies_parsed_at":"2024-09-07T15:36:39.648Z","dependency_job_id":"be700743-6255-4b59-8657-c2731f587493","html_url":"https://github.com/nelvko/clash-for-linux-install","commit_stats":null,"previous_names":["coolapker/clash-for-linux-install","nelvko/clash-for-linux-install"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nelvko%2Fclash-for-linux-install","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nelvko%2Fclash-for-linux-install/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nelvko%2Fclash-for-linux-install/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nelvko%2Fclash-for-linux-install/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nelvko","download_url":"https://codeload.github.com/nelvko/clash-for-linux-install/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254235701,"owners_count":22036964,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clash","linux","mihomo","subconverter"],"created_at":"2025-03-21T03:18:44.639Z","updated_at":"2025-05-14T22:09:15.566Z","avatar_url":"https://github.com/nelvko.png","language":"Shell","funding_links":[],"categories":["Shell","🌏开源项目"],"sub_categories":[],"readme":"# Linux 一键安装 Clash\n\n![GitHub License](https://img.shields.io/github/license/nelvko/clash-for-linux-install)\n![GitHub top language](https://img.shields.io/github/languages/top/nelvko/clash-for-linux-install)\n![GitHub Repo stars](https://img.shields.io/github/stars/nelvko/clash-for-linux-install)\n\n![preview](resources/preview.png)\n\n- 默认安装 `mihomo` 内核，[可选安装](https://github.com/nelvko/clash-for-linux-install/wiki/FAQ#%E5%AE%89%E8%A3%85-clash-%E5%86%85%E6%A0%B8) `clash`。\n- 自动使用 [subconverter](https://github.com/tindy2013/subconverter) 进行本地订阅转换。\n- 多架构支持，适配主流 `Linux` 发行版：`CentOS 7.6`、`Debian 12`、`Ubuntu 24.04.1 LTS`。\n\n## 快速开始\n\n### 环境要求\n\n- 用户权限：`root`、`sudo`。（无权限可参考：[#91](https://github.com/nelvko/clash-for-linux-install/issues/91)）\n- `shell` 支持：`bash`、`zsh`。\n\n### 一键安装\n\n下述命令适用于 `x86_64` 架构，其他架构请戳：[一键安装-多架构](https://github.com/nelvko/clash-for-linux-install/wiki#%E4%B8%80%E9%94%AE%E5%AE%89%E8%A3%85-%E5%A4%9A%E6%9E%B6%E6%9E%84)\n\n```bash\ngit clone --branch master --depth 1 https://gh-proxy.com/https://github.com/nelvko/clash-for-linux-install.git \\\n  \u0026\u0026 cd clash-for-linux-install \\\n  \u0026\u0026 sudo bash install.sh\n```\n\n\u003e 如遇问题，请在查阅[常见问题](https://github.com/nelvko/clash-for-linux-install/wiki/FAQ)及 [issue](https://github.com/nelvko/clash-for-linux-install/issues?q=is%3Aissue) 未果后进行反馈。\n\n- 上述克隆命令使用了[加速前缀](https://gh-proxy.com/)，如失效请更换其他[可用链接](https://ghproxy.link/)。\n- 默认通过远程订阅获取配置进行安装，本地配置安装详见：[#39](https://github.com/nelvko/clash-for-linux-install/issues/39)\n- 没有订阅？[click me](https://次元.net/auth/register?code=oUbI)\n\n### 命令一览\n\n执行 `clash` 列出开箱即用的快捷命令。\n\n\u003e 兼容多种风格\n\n```bash\n$ clash\nUsage:\n    clash     COMMAND [OPTION]\n    mihomo    COMMAND [OPTION]\n    clashctl  COMMAND [OPTION]\n    mihomoctl COMMAND [OPTION]\n\nCommands:\n    on                   开启代理\n    off                  关闭代理\n    ui                   面板地址\n    status               内核状况\n    tun      [on|off]    Tun 模式\n    mixin    [-e|-r]     Mixin 配置\n    secret   [SECRET]    Web 密钥\n    update   [auto|log]  更新订阅\n```\n\n### 优雅启停\n\n```bash\n$ clashoff\n😼 已关闭代理环境\n\n$ clashon\n😼 已开启代理环境\n```\n\n\u003cdetails\u003e\n\n\u003csummary\u003e原理\u003c/summary\u003e\n\n- 使用 `systemctl` 控制 `clash` 启停，并调整代理环境变量的值（http_proxy 等）。应用程序在发起网络请求时，会通过其指定的代理地址转发流量，不调整会造成：关闭代理但未卸载代理变量导致仍转发请求、开启代理后未设置代理地址导致请求不转发。\n- `clashon` 等命令封装了上述流程。\n\n\u003c/details\u003e\n\n### Web 控制台\n\n```bash\n$ clashui\n╔═══════════════════════════════════════════════╗\n║                😼 Web 控制台                  ║\n║═══════════════════════════════════════════════║\n║                                               ║\n║     🔓 注意放行端口：9090                      ║\n║     🏠 内网：http://192.168.0.1:9090/ui       ║\n║     🌏 公网：http://255.255.255.255:9090/ui   ║\n║     ☁️ 公共：http://board.zash.run.place      ║\n║                                               ║\n╚═══════════════════════════════════════════════╝\n\n$ clashsecret 666\n😼 密钥更新成功，已重启生效\n\n$ clashsecret\n😼 当前密钥：666\n```\n\n- 通过浏览器打开 Web 控制台，实现可视化操作：切换节点、查看日志等。\n- 控制台密钥默认为空，若暴露到公网使用建议更新密钥。\n\n### 订阅更新\n\n```bash\n$ clashupdate https://example.com\n👌 备份配置：/opt/clash/config.yaml.bak\n🍃 下载成功：内核验证配置...\n🍃 订阅更新成功\n\n$ clashupdate auto [url]\n😼 定时任务设置成功\n\n$ clashupdate log\n✅ [2025-02-23 22:45:23] 订阅更新成功：https://example.com\n```\n\n- `clashupdate` 会记忆安装和更新成功时的订阅，后续执行无需再指定订阅 `url`。\n- 可通过 `crontab -e` 修改定时更新频率及订阅链接。\n- 通过配置文件进行更新：[pr#24](https://github.com/nelvko/clash-for-linux-install/pull/24#issuecomment-2565054701)\n\n### `Tun` 模式\n\n```bash\n$ clashtun\n😾 Tun 状态：关闭\n\n$ clashtun on\n😼 Tun 模式已开启\n```\n\n- 作用：实现本机及 `Docker` 等容器的所有流量路由到 `clash` 代理、DNS 劫持等。\n- 原理：[clash-verge-rev](https://www.clashverge.dev/guide/term.html#tun)、 [clash.wiki](https://clash.wiki/premium/tun-device.html)。\n\n### `Mixin` 配置\n\n```bash\n$ clashmixin\n😼 less 查看 mixin 配置\n\n$ clashmixin -e\n😼 vim 编辑 mixin 配置\n\n$ clashmixin -r\n😼 less 查看 运行时 配置\n```\n\n- 作用：用来存储自定义配置，防止更新订阅后覆盖丢失自定义配置内容。\n- 运行时配置是订阅配置和 `Mixin` 配置的并集。\n- 相同配置项优先级：`Mixin` 配置 \u003e 订阅配置。\n\n### 卸载\n\n```bash\nsudo bash uninstall.sh\n```\n\n## 常见问题\n\n[wiki](https://github.com/nelvko/clash-for-linux-install/wiki/FAQ)\n\n## 引用\n\n- [Clash 知识库](https://clash.wiki/)\n- [Clash 家族下载](https://www.clash.la/releases/)\n- [Clash Premium 2023.08.17](https://downloads.clash.wiki/ClashPremium/)\n- [mihomo v1.19.2](https://github.com/MetaCubeX/mihomo)\n- [subconverter v0.9.0：本地订阅转换](https://github.com/tindy2013/subconverter)\n- [yacd v0.3.8：Web 控制台](https://github.com/haishanh/yacd)\n- [yq v4.45.1：处理 yaml](https://github.com/mikefarah/yq)\n\n## Thanks\n\n[@鑫哥](https://github.com/TrackRay)\n\n## 特别声明\n\n1. 编写本项目主要目的为学习和研究 `Shell` 编程，不得将本项目中任何内容用于违反国家/地区/组织等的法律法规或相关规定的其他用途。\n2. 本项目保留随时对免责声明进行补充或更改的权利，直接或间接使用本项目内容的个人或组织，视为接受本项目的特别声明。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnelvko%2Fclash-for-linux-install","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnelvko%2Fclash-for-linux-install","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnelvko%2Fclash-for-linux-install/lists"}