通過代理上網(wǎng)的時候,會遇到很多的問題。特別是利用終端去下載軟件的時候更是如此。

公司的IP

公司的代理
export http_proxy=http://代理ip:端口
export https_proxy=http://代理ip:端口
這兩天指令可以讓當前終端端口的下載指令都通過設置的代理下載數(shù)據(jù)。但是一旦關閉當前端口,設置就會失效。
但通過下面的方式可以將設置的內(nèi)容保存下來,每次新建一個終端的端口仍然可以使用設置的代理。

終端設置代理
vim ~/.bash_profile 可以編輯.bash_profile的文件內(nèi)容,設置https/http代理
source ~/.bash_profile
cat ~/.bash_profile
通過上面三個命令,之后每次新建的終端都是可以使用設置好的代理,而不用每次新建一個終端都需要輸入export 命令分別設置http、https代理了。
echo $http_proxy
echo $https_proxy
兩個命令可以查看當前的http、https代理
| name | function |
|---|---|
| echo $http_proxy | check http porxy |
| echo $https_proxy | check https proxy |
| export http_proxy=http://ip:port | set http proxy |
| export https_proxy=https://ip:port | set https proxy |
| export ALL_proxy=http://ip:port | set http&https proxy |
| vim ~/.bash_profile | edit Mac proxy file |
| source ~/.bash_profile | save .bash_profile settings |
| cat ~/.bash_profile | use .bash_profile settings |