Skip to the essay
ShemolSetting up Clash on Ubuntu (Zorin)
流程记录

Setting up Clash on Ubuntu (Zorin)

Some files in this post are better downloaded ahead of time, or you may not be able to get them because of network issues. Skim the whole thing first.

Reference: http://jemlab.cn/?p=141

Download clash and set it up

  • Download the latest Clash with:
plain text
wget <https://github.com/Dreamacro/clash/releases/download/v1.18.0/clash-linux-amd64-v1.17.0.gz>

Usually you have to redo this stuff when you switch to a new system, right? So download it in advance and keep it on a USB stick or somewhere. Otherwise downloading from GitHub later is just luck.

  • Go into the directory with the file, unzip
plain text
gunzip clash-linux-amd64-v1.18.0.gz
  • Rename clash-linux-amd64-v1.18.0 to clash
plain text
mv clash-linux-amd64-v1.18.0 clash
  • Create a folder in this directory (uppercase Clash just to tell it apart from clash)
plain text
mkdir Clash
  • Move the clash file into the Clash folder
plain text
mv clash ./Clash
  • Enter the Clash folder
plain text
cd Clash
  • Download the clash config config.yaml (note: this subscription URL is yours; replace [subscription-url]; if it fails, the subscription URL is the problem)
plain text
wget -O config.yaml [subscription-url]

Note: if step 7 fails, it's fine — skip it; it'll download automatically later. You can also download Country.mmdb from that URL.

Note: better to download this in advance too, or it may fail because of the network

  • Start clash
plain text
chmod +x clash
./clash -d .
  • Open system settings, click Network, find system proxy, choose Manual
HTTP proxy: 127.0.0.1:7890
HTTPS proxy: 127.0.0.1:7890
SOCKS proxy: 127.0.0.1:7891

That starts the system proxy

I don't remember having to enter HOST, port, or secret — just Save and OK. You can switch nodes right on the panel

Start on boot

Some of this may need admin. I don't remember. If you get Permission denied, put sudo in front

  • Create the service file
plain text
touch /etc/systemd/system/clash.service
  • Edit the service file
plain text
vim /etc/systemd/system/clash.service
  • Put in the following (look up how to use vim yourself
plain text
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

The path in ExecStart is wherever clash actually lives; change it to match your Clash folder

  • Enable Clash on boot, check status. Once the service is up, set your client's proxy protocol and port from that info (run these in order)
plain text
sudo systemctl daemon-reload
sudo systemctl enable clash
sudo systemctl start clash
sudo systemctl status clash

Afterword

On Arch Linux, Ubuntu, and Zorin the steps above were fine. When I switched to Fedora I hit a permission problem.

plain text
$ 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

plain text
sudo vim /etc/sysconfig/selinux
plain text
SELINUX=permissive