ubuntu设置系统代理

安装trojan等代理工具并配置启动,得到端口号

例如

10.10.1.10:8080

系统代理设置

我们将在/etc/profile.d/proxy.sh下添加一个shell脚本文件,这将确保设置适用于所有已登录的用户:

sudo vim  /etc/profile.d/proxy.sh

将以下内容写到文档中:

 # set proxy config via profie.d - should apply for all users
export http_proxy="http://10.10.1.10:8080/"
export https_proxy="http://10.10.1.10:8080/"
export ftp_proxy="http://10.10.1.10:8080/"
export no_proxy="127.0.0.1,localhost"
# For curl
export HTTP_PROXY="http://10.10.1.10:8080/"
export HTTPS_PROXY="http://10.10.1.10:8080/"
export FTP_PROXY="http://10.10.1.10:8080/"
export NO_PROXY="127.0.0.1,localhost"
#将要从代理中排除的其他IP添加到NO_PROXY和no_proxy环境变量中

为该文件填加执行权限:

sudo chmod +x  /etc/profile.d/proxy.sh

激活文件以开始使用代理设置,或者注销并重新登录:

source /etc/profile.d/proxy.sh
#查看环境变量进行确认是否生效
env | grep -i proxy

清除代理

unset http_proxy

unset https_proxy

unset HTTP_PROXY

unset HTTPS_PROXY
相关推荐
likfishdn11 分钟前
Linux的文件与目录管理
linux·运维·服务器
渲染101专业云渲染13 分钟前
川翔云电脑优势总结
服务器·3d·电脑·blender·maya
chian-ocean31 分钟前
Linux 文件缓冲区:高效数据访问的幕后推手
linux·运维·服务器
加油=^_^=32 分钟前
【Linux】进程优先级 | 进程调度(三)
linux·运维·服务器
若云止水41 分钟前
Ubuntu 下 nginx-1.24.0 源码分析 - ngx_init_cycle 函数 - 详解(4)
数据库·nginx·ubuntu
橘子味的茶二42 分钟前
高级系统架构师--第十章:计算机网络
服务器·计算机网络·系统架构
吃汤圆的抹香鲸1 小时前
GoLand 安装包 绿色版 Win,Mac,Linux 包含IntelliJ全家桶 专为Go语言设计的集成开发环境(IDE)
linux·windows·macos·go·intellij-idea·go1.19
紫菜(Nori)1 小时前
短连接服务器压测-wrk
服务器·压力测试
追寻光1 小时前
Cannot find a valid baseurl for repo: base/7/x86_64
linux
元气满满的热码式1 小时前
Docker数据卷操作实战
linux·运维·docker·云原生·容器