Magento Expert Forum - Improve your Magento experience

Results 1 to 7 of 7

Setting the PATH in Linux

  1. #1
    Junior Member ccvv's Avatar
    Join Date
    Mar 2013
    Posts
    64
    Thanks
    6
    Thanked 17 Times in 13 Posts

    Thumbs up Setting the PATH in Linux

    This article explains how set your PATH variable under Linux. This has the same use as that of setting the PATH variable under DOS. Under Linux too, modifying the PATH would add these new directories to your default search path. 
    So in case you have a particular executable in a particular directory, then if you add that directory to your PATH, then you would only have to type the name of the executable at the prompt rather than then absolute path for that executable. Got it?? Read the example below to figure out what exactly I am speaking about..

    Assumption

    Suppose you have a program by the name 'tetris' in a folder called /usr/local/games . So in order to run this program you would have to type the following at the prompt

    Code:
    $/usr/local/games/tetris
    The above command would execute your program. But typing this every time you want to play this wonderful game makes it slightly cumbersome. It would be much better if you could only type 'tetris'.


    Solution

    A solution would be to add the /usr/local/games directory to your PATH, so that next time onwards you would only have to type 'tetris' at the prompt rather than the absolute path. 

    To add this directory to your PATH you have to edit a file called 'bash_profile' that would be present in your Home directory (in Redhat Linux 6.2). So if there is a user by the name David then this file would mostly be found at /home/David/.bash_profile

    Note : The period (.) before the name of the file. This period make this file a hidden file. So remember to view hidden files also while seeing a directory listing (This option would be in some menu in X , at the prompt simply use 'ls -a' to see hidden files).

    This file would be having a particular line starting with the string PATH. For e.g. the file that I have on my machine has a line such as

    Code:
    PATH=/optional/bin:$PATH:$HOME/bin
     

    To add the directory /usr/local/games to this I would have to modify this line as follows

    Code:
    PATH=/usr/local/games:optional/bin:$PATH:$HOME/bin
    Once you have modified this file, save it and then execute it as follows 

    Code:
    . $HOME/.bash_profile 
    Note : To execute this script basically at the $ prompt type a period ' . ' leave a space and then type $HOME/ Once this is done press <Tab> key. Doing so would replace what ever you have typed with the path to your home directory. Once this happens all you have to do is append a .bash_profile to what is already present at the prompt and finally press <Enter>

    On executing the script you wouldn't see any messages at the output, but then onwards you could simply type 'tetris' at the prompt to execute the program /usr/local/games/tetris 

    So now you are on the right PATH ;-)

    View more threads in the same category:


  2. #2
    Junior Member
    Join Date
    Sep 2018
    Location
    United Kingdom
    Posts
    635
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Default

    You may set $PATH for all time in 2 different ways.

    To set way for specific client : You may need to make the passage in .bash_profile in home index in the client.

    To set regular way for ALL framework clients, you may need to set way like this : [root~]# reverberation "send out PATH=$PATH:/way/to/dir" >>/and so forth/profile.

  3. #3
    Junior Member
    Join Date
    Sep 2018
    Location
    Oman, Muscat
    Posts
    2,084
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Default

    The main method of setting your $PATH for all time is to change the $PATH variable in your Bash profile document, situated at/home/<user>/.bash_profile .

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •