How to Set Proxy for Command prompt in Linux?

Vkratse explain situeyshn.
1. Took the old archwiki - pow
2. Read the article on Shelake - pow
3. Asked a question earlier on the Toaster and I still feel - pow

So, in my "~/.bashrc" is written:
# Enable Proxy
function setproxy() {
 export http_proxy=http://proxy_server:port/
 export https_proxy=$http_proxy
 export ftp_proxy=$http_proxy
 export rsync_proxy=$http_proxy
 export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"
}

# Disable Proxy
unsetproxy function() {
 unset {http,https,ftp,rsync_proxy,no_proxy}_proxy
}

where under "http://proxy_server:port/" saw your real data

Accordingly, reload your bash:
. ~/.bashrc

Here is the result of the work done:
[thenovalive@hp_pavilion_g6 ~]$ sudo pacman -Syu
[sudo] password for thenovalive: **********
:: Update the databases of packages...
error: failed to get file 'core.db' from mirror.yandex.ru : Connection timed out after 10001 milliseconds
error: failed to get file 'core.db' from archlinux.polymorf.fr : Connection timed out after 10001 milliseconds
^C
Interrupt signal received

[thenovalive@hp_pavilion_g6 ~]$


Waiting for help.
PS: If the environment matters, I have Archlinux with KDE (last Plasma) and NetworkManager, which is also in archwiki read everything and found no good advice "How to configure a proxy?!".

ATP to all those involved!!!
July 12th 19 at 16:55
2 answers
July 12th 19 at 16:57
Solution
in my "~/.bashrc" is written:

It's just two functions, their somebody causes? After rebooting,~/.bashrc echo $http_proxy writes that it is necessary?
I do not understand Your answer, but after a reboot, bash in the terminal, of course, include the proxy: "setproxy". Just did not write it in the header, because the fool is clear that to enable/disable the proxy manually.
I hope that is what You mean?! - melisa_Pouros commented on July 12th 19 at 17:00
it. echo $http_proxy writes that it is necessary after setproxy? - anne_Stiedema commented on July 12th 19 at 17:03
As you can see, nothing happens, code below:

[thenovalive@hp_pavilion_g6 ~]$ ~/.bashrc echo $http_proxy
bash: /home/thenovalive/.bashrc: access Denied
[thenovalive@hp_pavilion_g6 ~]$ ~/.bashrc
bash: /home/thenovalive/.bashrc: access Denied
[thenovalive@hp_pavilion_g6 ~]$ . ~/.bashrc
[thenovalive@hp_pavilion_g6 ~]$ setproxy
[thenovalive@hp_pavilion_g6 ~]$ . ~/.bashrc echo $http_proxy
[thenovalive@hp_pavilion_g6 ~]$ sudo pacman -Syu
[sudo] password for thenovalive:
:: Update the databases of packages...
error: failed to get file 'core.db' from mirror.yandex.ru : Connection timed out after 10001 milliseconds
^C
Interrupt signal received

[thenovalive@hp_pavilion_g6 ~]$ yaourt -Syua
:: Update the databases of packages...
error: failed to get file 'core.db' from mirror.yandex.ru : Connection timed out after 10001 milliseconds
^C
Interrupt signal received

[thenovalive@hp_pavilion_g6 ~]$ ^C
[thenovalive@hp_pavilion_g6 ~]$ - melisa_Pouros commented on July 12th 19 at 17:06
What is all this nonsense? To load the script:
. ~/.bashrc
To perform the function:
setproxy
Print the value of a variable:
echo $http_proxy

Run these three commands in turn and show the output. - anne_Stiedema commented on July 12th 19 at 17:09
: ATP brought my proxies. I can't describe because I can calculate, but can lead to such a mind: "http://X.X.X.X:Y/" - melisa_Pouros commented on July 12th 19 at 17:12
OK, now sudo bash -c 'echo $http_proxy' - anne_Stiedema commented on July 12th 19 at 17:15
I suspect that will not print. sudo visudo and sudoers add the line

Defaults env_keep += "http_proxy https_proxy no_proxy ftp_proxy rsync_proxy" - anne_Stiedema commented on July 12th 19 at 17:18
:
OK, now sudo bash -c 'echo $http_proxy'
Written 30 minutes ago

[thenovalive@hp_pavilion_g6 ~]$ sudo bash -c 'echo $http_proxy'
[sudo] password for thenovalive:

[thenovalive@hp_pavilion_g6 ~]$ - melisa_Pouros commented on July 12th 19 at 17:21
: I suspect that will not print. sudo visudo and sudoers add the line

Defaults env_keep += "http_proxy https_proxy no_proxy ftp_proxy rsync_proxy"

HURRAY!!! ATP, You're HUGE!!! Did it!!! How much time could not do!!! More than a year!!!
Because I have not yuzal vi text editor did:
sudo EDITOR=nano visudo
and at the end of the file added the coveted spot:
Defaults env_keep += "http_proxy https_proxy no_proxy ftp_proxy rsync_proxy"

Then checked out!!!:
[thenovalive@hp_pavilion_g6 ~]$ . ~/.bashrc
[thenovalive@hp_pavilion_g6 ~]$ setproxy
[thenovalive@hp_pavilion_g6 ~]$ echo $http_proxy
X. X. X. X:Y
[thenovalive@hp_pavilion_g6 ~]$ sudo pacman -Syu
[sudo] password for thenovalive:
:: Update the databases of packages...
core is not outdated
extra 1792,7 KiB 974K/s 00:02 [############################################################] 100%
community MiB 3,4 3,96 M/s 00:01 [############################################################] 100%
multilib is not obsolete
archlinuxfr is not obsolete
infinality-bundle of 4.3 KiB 0,00 B/s 00:00 [############################################################] 100%
infinality-bundle.sig 287,0 B 0,00 B/s 00:00 [############################################################] 100%
infinality-bundle-fonts is not obsolete
:: Starting full system upgrade...
warning: kodi: skipping package upgrade (16.0-2 => 16.1-2)
warning: linux: skipping package upgrade (4.4.5-1 => 4.5.1-1)
resolving dependencies...
conflict checks...

Packages (8) cairo-infinality-ultimate-1.14.6-2 freetype2-infinality-ultimate-2.6.3-4 fuse-2.9.6-1 jre7-openjdk-7.u101_2.6.6-1 jre7-openjdk-headless-7.u101_2.6.6-1
lib32-libdrm-2.4.68-1 python-setuptools-1:21.0.0-1 python2-setuptools-1:21.0.0-1

Will uploaded: 44,06 MiB
Will be installed: 86,58 MiB
Resize: 0,27 MiB

:: Proceed with installation? [Y/n] y
:: Retrieving packages...
fuse-2.9.6-1-x86_64 109,5 KiB 370K/s 00:00 [############################################################] 100%
jre7-openjdk-headless-7.u101_2.6.6-1-x86_64 42,1 MiB of 7.47 M/s 00:06 [############################################################] 100%
jre7-openjdk-7.u101_2.6.6-1-x86_64 157,0 KiB 613K/s 00:00 [############################################################] 100%
python-setuptools-1:21.0.0-1-any 229,6 KiB 219K/s 00:01 [############################################################] 100%
python2-setuptools-1:21.0.0-1-any 216,0 KiB 272K/s 00:01 [############################################################] 100%
....
(8/8) upgrading python2-setuptools [############################################################] 100%
:: Running post-transaction hooks...
(1/2) Updating icon theme caches...
(2/2) Updating the desktop file MIME type cache...
[thenovalive@hp_pavilion_g6 ~]$ - melisa_Pouros commented on July 12th 19 at 17:24
July 12th 19 at 16:59
sudo on all your variables and functions looks like ...

export a=123

$ env |grep ^a
a=123

$ sudo env |grep ^a


Use values after sudo
Do not understand. Give a more detailed answer, and that is something don't understand ((( - melisa_Pouros commented on July 12th 19 at 17:02
: environmental variables responsible for proxy disappear when you use sudo. Do not use sudo if possible, or install proxy variables after a sudo. - anne_Stiedema commented on July 12th 19 at 17:05
: not necessarily. It depends on the sudoers configuration - which environment variables are erased. In not possible to specify that the variables are not erased. Actually on the car say uncomfortable when doing sudo bash - and both are two, it floated away. - melisa_Pouros commented on July 12th 19 at 17:08

Find more questions by tags ProxyLinux