1.临时生效性(只对当前会话有效)
export http_proxy="socks://192.168.0.1:10808"
2.永久生效性
(1)在/etc/profile尾部添加(这个文件是每个用户登录时都会运行的环境变量)
export http_proxy="socks://192.168.0.106:10808"
export https_proxy="socks://192.168.0.106:10808"
(2)在/etc/profile.d/下面添加一个.sh文件
比如/etc/profile.d/edison_proxy.sh
里面的内容是:
export http_proxy="socks://192.168.0.106:10808"
export https_proxy="socks://192.168.0.106:10808"
export http_proxy="http://localhost:10809"
export https_proxy="https://localhost:10809"
unset http_proxy
unset https_proxy
设置环境变量用export,相对应取消环境变量则用unset,
查看环境变量用$,其他同上。
备注:
永久生效的方法需要在编辑、添加好文件后执行source 命令:
source /etc/profile或者source /etc/profile.d/edison_proxy.sh才会生效
其他已存在会话窗口想要让上述环境变量生效也必须执行source命令
如果觉得《linux取消设置环境变量 linux设置环境变量》对你有帮助,请点赞、收藏,并留下你的观点哦!