Linux Tips

Set PATH

PATH=/usr:/bin/:usr/local/bin:.

This is a very important environment variable. This sets the path that the shell would be looking at when it has to execute any program. It would search in all the directories that are present in the above line. Remember that entries are separated by a ‘ : ‘ . You can add any number of directories to this list. The above 3 directories entered is just an example.

Note : The last entry in the PATH command is a ‘ . ‘ (period). This is an important addition that you could make in case it is not present on your system. The period indicates the current directory in Linux. That means whenever you type a command, Linux would search for that program in all the directories that are in its PATH. Since there is a period in the PATH, Linux would also look in the current directory for program by the name (the directory from where you execute a command). Thus whenever you execute a program which is present in the current directory (maybe some scripts you have written on your own) you don’t have to type a ‘ ./programname ‘ . You can only type ‘ programname ‘ since the current directory is already in your PATH.

Remember that the PATH variable is a very important variable. In case you want to add some particular directory to your PATH variable and in case you try typing the following

PATH =/newdirectory

This would replace the current PATH value with the new value only. What you would want is to append the new directory to the existing PATH value. For that to happen you should type

PATH=$PATH:/newdirectory

This would add the new directory to the existing PATH value. Always a $VARIABLE is substituted with the current value of the variable.

Advertisements

About sangroyaamit

I am a PhD student in computer science at INRIA Grenoble.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s