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
相关推荐
陈苏同学2 分钟前
4. 将pycharm本地项目同步到(Linux)服务器上——深度学习·科研实践·从0到1
linux·服务器·ide·人工智能·python·深度学习·pycharm
Ambition_LAO7 分钟前
解决:进入 WSL(Windows Subsystem for Linux)以及将 PyCharm 2024 连接到 WSL
linux·pycharm
Pythonliu724 分钟前
茴香豆 + Qwen-7B-Chat-Int8
linux·运维·服务器
你疯了抱抱我25 分钟前
【RockyLinux 9.4】安装 NVIDIA 驱动,改变分辨率,避坑版本。(CentOS 系列也能用)
linux·运维·centos
追风赶月、26 分钟前
【Linux】进程地址空间(初步了解)
linux
栎栎学编程26 分钟前
Linux中环境变量
linux
我是哈哈hh40 分钟前
专题十_穷举vs暴搜vs深搜vs回溯vs剪枝_二叉树的深度优先搜索_算法专题详细总结
服务器·数据结构·c++·算法·机器学习·深度优先·剪枝
郭二哈44 分钟前
C++——模板进阶、继承
java·服务器·c++
挥剑决浮云 -1 小时前
Linux 之 安装软件、GCC编译器、Linux 操作系统基础
linux·服务器·c语言·c++·经验分享·笔记
立秋67891 小时前
Python的defaultdict详解
服务器·windows·python