Setting Path in Linux

Setting a path information in windows is always been easier, since there is a GUI facility “Environmental Variables”, but I Linux setting a path is always been tricky and it should be done through CLI (Command Line Interface).  Here are the following ways to do:

Method 1:

For each user (Your login id) of Linux has a home folder (/home/username), there will be a file called as .bashrc (Ubuntu and Fedora) or .bash_profile (Fedora), whatever path has to be set, it should be entered in the above file.

For example: if the software is installed in /home/username/software1/, then the PATH has to be set in the .bashrc or .bash_profile file like this

export PATH=$PATH:/home/username/software1/

($PATH is a shell variable refers to the previous set path also to be included in the PATH setting.)

For Java Home

export JAVA_HOME=/home/username/<Java_path>

Method 2:

The above method of path is applicable only for that user. if other users wanted to access the software, then they have to set the paths. Because, for each user of Linux, the .bashrc or .bash_profile file exists.

if the same path is set for all the users, then the super user can set the path information in the following file

/etc/profile.d/your_path_name.sh

Open the file name (of your choice, but the extension is .sh) and has to be stored in /etc/profile.d/

This folder will be read during the booting process, so all the users of that machine will be able to access the software. The following line is copied to the shell file

export PATH=$PATH:/home/username/software1/

export JAVA_HOME=/home/username/<Java_path>

Comments

Popular Posts