# Linux

Linux 没有统一的全局代理设置——分 shell 环境变量、桌面环境（GNOME / KDE）、各应用自配几条线。本页给出实际需要的模式。

## 环境变量（命令行 + 多数应用）

事实标准。curl、wget、apt、pip、npm、git 及大多数服务都识别。

```bash
export http_proxy="http://helo_s1a2b3c4d5e-type-res-region-us:PASSWORD@gate.helodata.io:7777"
export https_proxy="$http_proxy"
export no_proxy="localhost,127.0.0.1,.local"
# 同时设大写变体——部分应用只认大写：
export HTTP_PROXY="$http_proxy"
export HTTPS_PROXY="$https_proxy"
export NO_PROXY="$no_proxy"
```

写到 `~/.bashrc`、`~/.zshrc` 或 `/etc/environment` 实现持久化。

## GNOME

```bash
gsettings set org.gnome.system.proxy mode 'manual'
gsettings set org.gnome.system.proxy.http  host 'gate.helodata.io'
gsettings set org.gnome.system.proxy.http  port 7777
gsettings set org.gnome.system.proxy.https host 'gate.helodata.io'
gsettings set org.gnome.system.proxy.https port 7777
```

GNOME 代理对话框不存凭证——用 secret-tool 或按应用配；更简单：在终端启动会话直接用环境变量。

## KDE

**系统设置 → 网络 → 代理 → 使用手动指定的代理**。同样填 host/port，凭证存到 KWallet。

## apt（Debian / Ubuntu）

新建 `/etc/apt/apt.conf.d/99helo-proxy`：

```
Acquire::http::Proxy "http://helo_s1a2b3c4d5e-type-res-region-us:PASSWORD@gate.helodata.io:7777";
Acquire::https::Proxy "http://helo_s1a2b3c4d5e-type-res-region-us:PASSWORD@gate.helodata.io:7777";
```

## yum / dnf（RHEL / Fedora）

写入 `/etc/yum.conf`（yum）或 `/etc/dnf/dnf.conf`（dnf）：

```
proxy=http://gate.helodata.io:7777
proxy_username=helo_s1a2b3c4d5e-type-res-region-us
proxy_password=PASSWORD
```

## Docker

守护进程级（影响镜像拉取）：

```bash
mkdir -p /etc/systemd/system/docker.service.d
cat > /etc/systemd/system/docker.service.d/proxy.conf <<EOF
[Service]
Environment="HTTP_PROXY=http://helo_s1a2b3c4d5e-type-res-region-us:PASSWORD@gate.helodata.io:7777"
Environment="HTTPS_PROXY=http://helo_s1a2b3c4d5e-type-res-region-us:PASSWORD@gate.helodata.io:7777"
EOF
systemctl daemon-reload
systemctl restart docker
```

容器级 — `docker run`/构建时 `--env http_proxy=…`。

## systemd 服务

让服务接收代理，在 unit 文件中加：

```
[Service]
Environment="HTTP_PROXY=http://helo_s1a2b3c4d5e-type-res-region-us:PASSWORD@gate.helodata.io:7777"
Environment="HTTPS_PROXY=http://helo_s1a2b3c4d5e-type-res-region-us:PASSWORD@gate.helodata.io:7777"
```

然后 `systemctl daemon-reload && systemctl restart <service>`。

## 验证

```bash
curl https://ipv4.icanhazip.com
```

## 常见陷阱

* **环境变量区分大小写** — 部分应用只识小写 `http_proxy`，部分只识大写，**两个都设**。
* **缺 `localhost` bypass** — 没有 `no_proxy=localhost`，本地开发服务器会被代理出去失败。
* **密码含特殊字符** — 嵌入 `http_proxy` 前 URL 编码（`@` → `%40`、`:` → `%3A`）。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.helodata.com/helodata-zh/ji-cheng-zhi-nan/cao-zuo-xi-tong/linux.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
