Linux终端走代理

Linux 让终端走代理的几种方法

两种代理方式

socks5://127.0.0.1:1080

http://127.0.0.1:12333

方法一

在终端中直接运行

1
2
export http_proxy=http://proxyAddress:port
export https_proxy=http://127.0.0.1:12333

方法二

把代理服务器地址写入shell配置文件.bashrc或者.zshrc 直接在.bashrc或者.zshrc添加下面内容

1
2
export http_proxy="http://localhost:port"
export https_proxy="http://localhost:port"

走socket5协议(ss,ssr)

1
2
export http_proxy="socks5://127.0.0.1:1080"
export https_proxy="socks5://127.0.0.1:1080"

直接设置ALL_PROXY

export ALL_PROXY=socks5://127.0.0.1:1080

最后在执行如下命令应用设置

source ~/.bashrc

通过设置alias简写来简化操作,每次要用的时候输入setproxy,不用了就unsetproxy

alias setproxy="export ALL_PROXY=socks5://127.0.0.1:1080" alias unsetproxy="unset ALL_PROXY"

使用ss/ssr来加快git的速度

1
2
git config --global http.proxy 'socks5://127.0.0.1:1080' 
git config --global https.proxy 'socks5://127.0.0.1:1080'