configure-clash-on-ubuntu-en
Download some files ahead of time if you can—otherwise network issues may block downloads; skim the whole post first.
Reference: http://jemlab.cn/?p=141
Download Clash and configure
- Download the latest Clash release:
wget <https://github.com/Dreamacro/clash/releases/download/v1.18.0/clash-linux-amd64-v1.17.0.gz>
On a fresh system you often redo this setup—save copies on a USB drive or similar, or GitHub downloads become hit-or-miss.
cdto the download directory and decompress:
gunzip clash-linux-amd64-v1.18.0.gz
- Rename the binary to
clash:
mv clash-linux-amd64-v1.18.0 clash
- Create a folder (uppercase
Clashhere is only to distinguish it from the binary):
mkdir Clash
- Move
clashintoClash:
mv clash ./Clash
- Enter the folder:
cd Clash
- Download
config.yaml(replace[subscription URL]with your own; failure usually means a bad subscription URL):
wget -O config.yaml [订阅链接]
If step 7 fails, you can skip it—later steps may download automatically. You can also fetch Country.mmdb manually. Again, prefetch if possible.
- Start Clash:
chmod +x clash
./clash -d .
-
Open system settings → Network → Proxy → Manual
HTTP proxy: 127.0.0.1:7890
HTTPS proxy: 127.0.0.1:7890
SOCKS proxy: 127.0.0.1:7891 -
Visit http://clash.razord.top/. Rule mode is recommended. I don’t recall needing host/port/secret—Save and Confirm. Switch nodes from the dashboard.
Boot service
Some steps may need root—if you see Permission denied, prefix with sudo.
- Create a unit file:
touch /etc/systemd/system/clash.service
- Edit it:
vim /etc/systemd/system/clash.service
- Example content (learn
vimbasics elsewhere):
Description=clash daemon
[Service]
Type=simple
User=root
ExecStart=/home/username/下载/Clash/clash -d /home/username/下载/Clash/ Restart=on-failure
[Install]
WantedBy=multi-user.target
Adjust ExecStart to your real Clash directory.
- Enable, start, check status, then point your clients at the right protocol/ports:
sudo systemctl daemon-reload
sudo systemctl enable clash
sudo systemctl start clash
sudo systemctl status clash
Postscript
The steps worked on Arch, Ubuntu, and Zorin. On Fedora I hit permission errors:
$ sudo systemctl status clash
● clash.service - A rule based proxy in Go for shitao.
Loaded: loaded (/usr/lib/systemd/system/clash.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Tue 2019-06-18 17:27:18 CST; 4s ago
Process: 6777 ExecStart=/usr/bin/clash (code=exited, status=203/EXEC)
Main PID: 6777 (code=exited, status=203/EXEC)
Jun 18 17:27:18 localhost.localdomain systemd[1]: Started A rule based proxy in Go for shitao..
Jun 18 17:27:18 localhost.localdomain systemd[6777]: clash.service: Failed to execute command: Permission denied
Jun 18 17:27:18 localhost.localdomain systemd[6777]: clash.service: Failed at step EXEC spawning /usr/bin/clash: Permission denied
Jun 18 17:27:18 localhost.localdomain systemd[1]: clash.service: Main process exited, code=exited, status=203/EXEC
Jun 18 17:27:18 localhost.localdomain systemd[1]: clash.service: Failed with result 'exit-code'.
Fix: set SELinux to permissive:
sudo vim /etc/sysconfig/selinux
SELINUX=permissive