内容纲要
目录
方法1
在终端中直接运行命令
export http_proxy=http://proxyAddress:port
这个办法的好处是简单直接,并且影响面很小(只对当前终端有效)。
方法2:
把代理服务器地址写入shell配置文件.bashrc或者.zshrc
直接在.bashrc或者.zshrc添加下面内容
export http_proxy="http://localhost:port"
export https_proxy="http://localhost:port"
方法3:
改相应工具的配置,比如apt的配置
sudo vim /etc/apt/apt.conf
在文件末尾加入下面这行
Acquire::http::Proxy "http://proxyAddress:port"
关于apt的代理设置可以参考这里
补充:
如果代理服务器需要登陆,这时可以直接把用户名和密码写进去
http_proxy=http://userName:password@proxyAddress:port
各种类型代理的写法
$ export http_proxy=socks5://127.0.0.1:1080 # 配置http 代理访问
$ export https_proxy=socks5://127.0.0.1:1080 # 配置https 代理访问
$ export all_proxy=socks5://127.0.0.1:1080 # 配置http和https访问
$ unset http_proxy # 取消http 代理访问
$ unset https_proxy # 取消https 代理访问
参考连接: https://blog.csdn.net/yyws2039725/article/details/90675347