Monday 14 August 2017

Modifying the path variable in linux machine

Hello all, we often need to modify the environment path setting to access our most used programs easily or to make them available to run from anywhere in the system so that dependent components can make use of them.

Usually, in a Windows machine, you have the comfort of setting the PATH by going into the System Properties -> Environment Variables and adding in a new entry, making your life easier.

But when people are changing from Windows to Linux environments, they find it difficult at least new comers to modify / tweak the path setting. So, I am writing this post to show you how to add your favourite programs to path in a Linux Machine.

In the Linux Machine Home(/home/username) directory, you have 2 files .bashrc and .profile. These 2 files manage the path entries in linux system. You can see these files in a file explorer by enabling hidden files. Press Ctrl + H in a folder to show your hidden files in the file explorer.

You can open the above files in your favorite file editor. You need to make an entry in the PATH variable which usually present at the end or somewhere in the file. In Windows, each path entry is separated with a ; In linux, each entry is separated by a colon :

Suppose you have an executable in a folder, copy the path to the folder and append it to the existing path. After adding the entry, you need to logout and login into the PC.

So, what is the catch in editing .bashrc and .profile both? The programs in the .bashrc are available only in the command line or terminal. Suppose if you want to run the program from a GUI like run prompt you see in windows, Alt + F2 in ubuntu, you have to make the change in .profile

If you want to make the program to be accessible only in Terminal mode, make entry in .bashrc
If you want to make the program to be accessible in both Terminal and GUI, make entry in .profile


I hope this post makes some sense and helps some one. Thanks :)

No comments:

Post a Comment

Please add your valuable comments.We appreciate it.