The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 02-27-2003
RTM's Avatar
RTM RTM is offline
Hog Hunter
 
Join Date: Apr 2002
Location: On my motorcycle
Posts: 3,039
Quote:
From www.math.psu.edu:
When you type a command to be executed, Unix looks in a predefined list of directories to find an executable file of the same name as the command and executes it. This predefined list is called your path. An all-too-common practice by many Unix users is to put the working directory ``.'' in their path so they can execute any executable file in their working directory, wherever they happen to be in the system, just by typing its name.

This is not a big savings: if ``.'' is not in your path you merely have to type ./mycommand instead of mycommand. Moreover, having ``.'' in your path, especially near the beginning of it, puts you at risk. A vandal might create an executable file called ls in some directory. If you are in that directory and type ls, thinking it will list the directory, you will execute the cracker's command; if he were nasty enough, the command could destroy your files or create security holes that the person can later exploit.
If you REALLY need it, create a script that changes your PATH to include your complete home path (ie. /home/username/bin) instead of . - this will at the least keep you from running the wrong scripts. You would then have to run . /home/username/myscript4path to source it to your process.

#!/bin/ksh
export PATH=$PATH:/home/username/bin
exit

(Sorry, haven't messed with bash - should be close though)