Adding Current Dir To The PATH

Follow The Path


For security reasons in Unix/Linux variant Operating Systems, the current directory is not included in the PATH.

Its a measure to plug possible security holes. You can't run commands in the current directory without specifically calling them.

ie ./myscript.sh 

To stop nasties writing a vicious shell script, placing the script in an innocent location such as /tmp and getting root to run the script. Would root run a nefarious script? If the script was named 'ls' and root did a listing, the script would automatically run.

To prevent such scenarious taking place, by default the current directory is excluded from the PATH.

That can be a pain if you want to run simple scripts yourself. The solution? Add your current directory to the PATH.

Add the following to .bash_profile or .profile start up files in your home dir:

export PATH=$PATH:.

Warning!!! Do not change root user's PATH.

Done!

No comments:

Post a Comment