windows cmd/linux terminal/git bash设置代理

本文详细介绍了在Windows cmd、Linux terminal及Git Bash中如何设置HTTP及SOCKS5代理的方法,并提供了临时及永久设置代理的具体步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. windows cmd代理设置

原文链接:Win/Linux 命令行、终端和 Git 代理设置

HTTP 代理设置:

set http_proxy=http://127.0.0.1:8118
set https_proxy=http://127.0.0.1:8118

SOCKS5 代理设置:

set http_proxy=socks5://127.0.0.1:1080
set https_proxy=socks5://127.0.0.1:1080

可以通过 echo %http_proxy% 命令查看是否设置成功。

取消代理设置:

set http_proxy=
set https_proxy=
2. linux terminal代理设置
2.1 临时代理设置

Linux 终端设置 HTTP 代理(只对当前终端有效):

$ export http_proxy=http://127.0.0.1:8118
$ export https_proxy=http://127.0.0.1:8118

Linux 中设置 SOCKS5 代理(只对当前终端有效):

$ export http_proxy=socks5://127.0.0.1:1080
$ export https_proxy=socks5://127.0.0.1:1080

设置终端中的 wget、curl 等都走 SOCKS5 代理(只对当前终端有效):

$ export ALL_PROXY=socks5://127.0.0.1:1080

Linux 终端中取消代理设置:

$ unset http_proxy
$ unset https_proxy
$ unset ALL_RPOXY
2.2 永久代理设置

将代理命令写入配置文件 ~/.profile 或 ~/.bashrc 或 ~/.zshrc 中:

3. git bash代理设置

设置 HTTP 代理:

git config --global http.proxy http://127.0.0.1:8118
git config --global https.proxy http://127.0.0.1:8118

设置 SOCKS5 代理:

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

Git 取消代理设置:

git config --global --unset http.proxy
git config --global --unset https.proxy
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值