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..


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

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'.


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

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

Once you have modified this file, save it and then execute it as follows
. $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 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

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

Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicious BlinkList Furl


Unknown said...

I've liked Nature's clipping path.

Unknown said...

Thanks for this awesome post.
high end beauty retouching
background removal service
image masking service

Clipping Path Service said...

Enjoyed reading the article on top of, very explains everything in detail, the article is extremely fascinating and effective. Thank you and smart luck for the approaching articles.

Mostafejur said...

Incredible tips and straightforward. This will be exceptionally helpful for me when I get an opportunity to begin my blog.

Sukhendra said...

I am always searching online for storys that can accommodate me. There is obviously a multiple to understand about this. I feel you made few salubrious points in Attributes moreover. dallas cowboys live game stream

Sumon Rana said...

Dazzling post. I Have Been examining about this issue. So a commitment of thankfulness is all together to post. Totally cool post. It 's incredibly exceptionally OK and Useful post.Thanks watch patriots games online free

Rima said...

Wow! Such an amazing and helpful post this is. I really really love it. It's so good and so awesome. I am just amazed. I hope that you continue to do your work like this in the future nfl games live stream

albina N muro said...

Thanks for taking the time to discuss that, I feel strongly about this and so really like getting to know more on this kind of field. Do you mind updating your blog post with additional insight? It should be really useful for all of us. buzzoid instagram likes

Unknown said...

Great Article Image Processing Projects Deep Learning Projects for Final Year JavaScript Training in Chennai JavaScript Training in Chennai The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training Project Centers in Chennai

orthoimplants said...

as seen on tv pakistan Thank you for taking the time to discuss this with me;charger mobile I have strong feelings about it and would welcome the opportunity to learn more about this particular topic. Would you mind editing your blog article to provide some further information? It should prove to be very beneficial to all of us.hdmi converter

Post a Comment

Popular Posts