10/27/2014

working with Linux OS behind proxy server (Linuxmint 17)

# Configuring proxy servers when you are using Linux/Windows operating system.

# In this case i am using Linux mint 17 - XFCE x64bit

# There are mostly two ways to configure proxy for Linux operating system tools.
    #1. First you can look for tool configuration file, that can be found in Linux System /etc directory,
    For example: If you are using WGET (Linux download manager) that its configuration file in
        /etc/wgetrc
        ~ And you need to edit this file to setup proxy for wget,
   
        #NOTE
                ~ This proxy will be configured for wget will be used every time you run wget.
           So, if you are using proxy for a while than you should avoid this method.

    #2. Second method for configuring proxy is using console/Terminal environment variable.

----------------------------------NOTE------------------------------------------------------------
Environment variables are very important and allows you to directly communicate with another 
command line application or look for any configuration file where that defined for your specific
Application.
A simple example is, So you have installed JAVA_JDK or you are going to install java into your SYSTEM,
How your SYSTEM is going to find that you have installed JAVA_JDK installed,
    -> You can say that path can be defined using windows registry. ok but what about linux?

Their is one another way to use it even without installing it,

    -> This is using Environment variables, these are specific for two scopes
        -> LOCAL Environment Variables
        -> GLOBAL Environment Variables    => need admin privileges
    -> export JAVA_HOME environment variable for that Directory where you have installed/extract
        java_jdk contents.
    -> And you are ready to go ..
----------------------------------------------------------------------------------------------------

         ~  for BASH shell on Linux mint17-XFCE-x64
         ~ I have used this command-
              $ export http_proxy=http://172.16.200.3:3128
          
              ~ So, what actually this is going to do?
                   ~ This actually create a new environment variable using :
                             KEY = http_proxy
                             VALUE= http://172.16.200.3:3128

            ~ If you want to see Environment variable, use env  command,
                   ~ $ env
                    # This is going to print every environment variable KEY and corresponding
                       key VALUES.

    # If you are using Linux tools using CYGWIN package
     https://www.cygwin.com/
     http://x.cygwin.com/

      ~You can set environment variable using set command on windows, 
            ~ There is Syntax
              >set http_proxy=http://172.16.200.3:3128
              >wget http://www.google.co.in 



    # Linux == export ( to define environment variables temporarily)
        ~ And to view them use == env  command
         http://www.computerhope.com/unix/uenv.htm

    # Windows == set ( to define environment variables temporarily on windows OS  )
        ~ And to view all of them use   == set command
        http://www.computerhope.com/sethlp.htm
       http://ss64.com/nt/set.html

# Some examples:
    #1. using wget command line download manager for UNIX like systems.
        ~LINUX
        $ export http_proxy=http://172.16.200.3:3128
       $ wget -o home.html http://python.org

                               OR

       $ http_proxy=http://172.16.200.3:3128 wget -o home.html http://python.org

                              OR

      ~ Use wget  configuration, edit and define proxy server and port for http, https, ftp protocol.
         # nano /ect/wgetrc

    #2. using pip python modules/packages management tool
        ~ LINUX
        $  export http_proxy=http://172.16.200.3:3128
        $ sudo pip install ipython[test, notebook, zmq, qtconsole]
        # This is how we can install IPython with notebook, qtconsole, zmq dependencies.

                                OR

        $ http_proxy=http://172.16.200.3:3128 pip install ipython[test, notebook, zmq, qtconsole]

                                 OR

        # use pre-defined option for proxy server
            $ sudo pip --proxy http://172.16.200.3:3128 install ipython

    #3. using apt-get to install Linux packages form console/terminal
    ~ Although you can use Synaptic package manager or GDebi package manager which are GUI
         for Linux package management, yet apt-get is most basic tool for managing packages on
         debian based Linux operating systems.

         ~ LINUX
         $ export http_proxy=http://172.16.200.3:3128
         $ sudo apt-get install ipython

                               OR

         # http_proxy=http://172.16.200.3:3128 apt-get install ipython

                               OR

       ~ edit configuration file for apt-get tool
          ~ which is apt.conf
          ~ PATH == /etc/apt/apt-conf
               # and now define proxy for this file, note that you can not edit this file untill
                  you have root user privileges.

                  #
         Acquire::http::Proxy "http://172.16.200.3:3128";
         #
 
    # edit your BASH configuration file that can be found in your HOME directory.
       ~/.bachrc 
 
       # Time to edit this file, nano is my favorite command line editor.
       # nano ~/.bashrc
         # go to the bottom of file and this line of code,
           of-course you are familiar with this code. 

         #
         http_proxy=http://172.16.200.3:3128
         export http_proxy
         # 

             # Save using ( CTRL+O )  and exit using ( CTRL+X )

    #4. Using easy_install behind proxy server
        $ export http_proxy=http://172.16.200.3:3128
        $ sudo -E easy_install  ipython



No comments :