笔记:Linux系统代理设置
本文最后更新于:2021-05-09
Linux下设置代理问题
Ref:
Proxy server - ArchWiki
Environment variables - ArchWiki
这两篇文档基本可以解决Linux下设置代理的各种问题
How To Use Proxy Server To Access Internet at Shell Prompt With http_proxy Variable
这篇是简单操作版
之前找了好多教程,都没搞清楚
到头来,发现还是好文档最靠谱
2019/12/23 更新
- 环境变量设置代理
在~/.bashrc
添加1
2
3
4
5export http_proxy=http://<proxy_addr>:<proxy_port>/
export https_proxy=$http_proxy
export ftp_proxy=$http_proxy
export rsync_proxy=$http_proxy
export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"
- sudo命令继承代理
参考 Sudo Environment variables
在/etc/sudoers
添加1
Defaults env_keep += "ftp_proxy http_proxy https_proxy no_proxy"
2021/02/24 update
不要直接更改sudoers
文件,而是在/etc/sudoers.d/
下增加一个文件比较好Ref:adding local content in /etc/sudoers.d/ instead of directly modifying sodoers file via visudo1
2
3
4$ sudo visudo /etc/sudoers.d/env_proxy
# Add following line
Defaults env_keep += "ftp_proxy http_proxy https_proxy no_proxy"
2021/05/09 update
1 |
|
Ref: ArchWiki - Proxy server: Keep proxy through sudo
Snap下载使用代理
参考 How to install snap packages behind web proxy on Ubuntu 16.04
命令行敲1
2$ sudo snap set system proxy.http="http://<proxy_addr>:<proxy_port>"
$ sudo snap set system proxy.https="http://<proxy_addr>:<proxy_port>"ubuntu sudo继承代理
参考 How to keep environment variables when using sudo
ubuntu的似乎还有一点区别,不能写在一行里面1
2
3
4
5
6
7
8sudo visudo
# For Ubuntu 14, you need to specify in separate lines as it returns the errors for multi-variable lines:
Defaults env_keep += "http_proxy"
Defaults env_keep += "https_proxy"
Defaults env_keep += "HTTP_PROXY"
Defaults env_keep += "HTTPS_PROXY"
2021/04/10 update
curl and pacman
Ref: ArchWiki - Proxy server: crul and pacman
You may set the all_proxy environment variable to let curl and pacman (which uses curl) use your socks5 proxy:
$ export all_proxy="socks5://your.proxy:1080"
本博客所有文章除特别声明外,均采用 CC BY-NC-ND 4.0协议 。转载请注明出处~