让终端走代理的几种方法

方法1:

在终端中直接运行命令

export http_proxy=http://proxyAddress:port

这个办法的好处是简单直接,并且影响面很小(只对当前终端有效)。

方法2:

把代理服务器地址写入shell配置文件.bashrc或者.zshrc

直接在.bashrc或者.zshrc添加下面内容

export http_proxy="http://localhost:port" 
export https_proxy="http://localhost:port"

以使用shadowsocks代理为例,ss的代理端口为1080,那么应该设置为

export http_proxy="http://127.0.0.1:1080" 
export https_proxy="http://127.0.0.1:1080"

localhost就是一个域名,域名默认指向 127.0.0.1,两者是一样的。

然后ESC:wq保存文件,接着在终端中执行

source ~/.bashrc

或者退出当前终端再起一个终端。 这个办法的好处是把代理服务器永久保存了,下次就可以直接用了。

方法3:

改相应工具的配置,比如apt的配置

sudo vim /etc/apt/apt.conf

在文件末尾加入下面这行

Acquire::http::Proxy "http://proxyAddress:port"

保存apt.conf文件即可。
关于apt的代理设置可以参考这里

关于git的代理设置看这里:用shadowsocks加速git clone

方法4:

利用proxychains在终端使用socks5代理

补充:

如果代理服务器需要登陆,这时可以直接把用户名和密码写进去

http_proxy=http://userName:password@proxyAddress:port

如果想恢复默认的配置,可以执行

 unset http_proxy HTTP_PROXY https_proxy HTTPS_PROXY 

103 thoughts on “让终端走代理的几种方法

  1. Pingback: have a peek here

  2. Pingback: find more

  3. Pingback: cornhole bags near me

  4. Pingback: movies

  5. Pingback: movies online

  6. Pingback: karan johar

  7. Pingback: Top Movies

  8. Pingback: Movies1

  9. Pingback: 11 10 2019

  10. Pingback: smotretonline2015.ru

  11. Pingback: Serial smotret

  12. Pingback: kinokrad

  13. Pingback: kinokrad 2020

  14. Pingback: ñïèñîê íîâûõ ôèëüìîâ

  15. Pingback: Watch Tv Series Online

  16. Pingback: casino

  17. Pingback: Kinokrad 2019 Kinokrad Hd

  18. Pingback: filmy-kinokrad

  19. Pingback: kinokrad-2019

  20. Pingback: filmy-2019-kinokrad

  21. Pingback: serial

  22. Pingback: paper die cuts

  23. Pingback: 바카라사이트

  24. Pingback: cerialest.ru

  25. Pingback: youtube2019.ru

  26. Pingback: dorama hdrezka

  27. Pingback: movies hdrezka

  28. Pingback: HDrezka

  29. Pingback: kinosmotretonline

  30. Pingback: LostFilm HD 720

  31. Pingback: Sex toys

  32. Pingback: trustedmdstorefy.com

  33. Pingback: bofilm ñåðèàë

  34. Pingback: bofilm

  35. Pingback: 1 seriya

  36. Pingback: Êîíñóëüòàöèÿ ïñèõîëîãà

  37. Pingback: topedstoreusa.com

  38. Pingback: hqcialismht.com

  39. Pingback: viagramdtrustser.com

  40. Pingback: Eddie Frenay

  41. Pingback: myonlinebuy.us

  42. Pingback: ignou mba project

  43. Pingback: 4serial.com

  44. Pingback: See-Season-1

  45. Pingback: Evil-Season-1

  46. Pingback: Evil-Season-2

  47. Pingback: Evil-Season-3

  48. Pingback: Evil-Season-4

  49. Pingback: Dollface-Season-1

  50. Pingback: Queer-Eye-We-re-in-Japan-Season-1

  51. Pingback: bridal shower picture frame prop

  52. Pingback: serial 2020

  53. Pingback: Dailymotion

  54. Pingback: Watch+movies+2020

  55. Pingback: serial-video-film-online

  56. Pingback: tvrv.ru

  57. Pingback: 1plus1serial.site

  58. Pingback: #1plus1

  59. Pingback: 1plus1

  60. Pingback: 2020

  61. Pingback: Watch Movies Online

  62. Pingback: Film

  63. Pingback: Film 2020

  64. Pingback: Film 2021

  65. Pingback: watch online TV LIVE

  66. Pingback: human design

  67. Pingback: dizajn cheloveka

  68. Pingback: human-design-space

  69. Pingback: hischnye-pticy-hisxne-ptic

  70. Pingback: The-Gentlemen

  71. Pingback: pod-vodoi

  72. Pingback: vk 2020

  73. Pingback: parazity-oskar-2020

  74. Pingback: DSmlka

  75. Pingback: viagra

  76. Pingback: viagra online

  77. Pingback: ¯jak Son³k

  78. Pingback: astrolog

  79. Pingback: film-kalashnikov-watch

  80. Pingback: generic cialis

  81. Pingback: cialis 20mg

  82. Pingback: watch online

  83. Pingback: generic viagra online canadian pharmacy

  84. Pingback: generic viagra 100mg

  85. Pingback: free viagra

  86. Pingback: kinoxaxru.ru

  87. Pingback: pobachennya u vegas

  88. Pingback: Proshanie so Stalinym

  89. Pingback: strelcov 2020

  90. Pingback: film t-34

  91. Pingback: online pharmacy

  92. Pingback: canadian pharmacy

  93. Pingback: generic cialis

  94. Pingback: sildenafil

  95. Pingback: buy viagra

  96. Pingback: Beograd film 2020

  97. Pingback: cialis

  98. Pingback: viagra online

  99. Pingback: psiholog

  100. Pingback: psyhelp_on_line

  101. Pingback: coronavirus

  102. Pingback: PSYCHOSOCIAL

  103. Pingback: rasstanovka hellinger

Comments are closed.