|
||||||
| Forums FAQ | Members List | Search | Today's Posts | Mark Forums Read |
| Applications Questions about desktops (KDE, Gnome, XFCE, etc.), software applications (configuration, usage, bugs, documentation) |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
To be able to run a program without the ./, the program must exist in your path. By default, the current working directory is not in the path. You can check your path by doing (in a terminal)
Code:
echo $PATH Code:
export PATH=$PATH:. |
|
||||
|
This practice is however not considered to be harmless. Especialy do not add . (current directory) to your PATH in the case of root!
Think of root standing somewhere in a directory being owned by 'some user' (root can go everywhere can't she/he?). And this 'some user' has an executable called ls there. Imagin what would happen if root tried a 'simple' ls there.
__________________
Henk van Velden |
|
||||
|
Thanks elserj and hcvv.
As I understand it, if the path of an executable is not defined in $PATH, you must explicitly include the full pathname of the file to execute it, which adding ./ does. I also tested this by typing at the command prompt Code:
~/path-to-file/filename
__________________
x86_64 openSUSE 11.1 (2.6.27.29-0.1-default) Gnome 2.24.1 |
|
||||
|
You are correct but one detail.
It is not required to type an absolute path, it may be relative. In fact ./ is relative (it does not start with /). But you are correct, when you do not provide a path yourself, the shell will look at your PATH environment variable and search from left to right in all the directories until it finds a file of the name you gave and then try to execute it. And it is the inclusion of relative pathes in the PATH variable (and ./ is the most (mis)used one here) that can create havoc because it depends upon what your working directory is at the very moment you call something where it will end up somewhere relative to that working directory.
__________________
Henk van Velden |
|
||||
|
Thanks hcvv,
That's what I meant.
__________________
x86_64 openSUSE 11.1 (2.6.27.29-0.1-default) Gnome 2.24.1 |
|
|||
|
Quote:
|
|
|||
|
It's less risky but there is still the possibility to take advantage of typing mistakes. The user could plant a command which is close to an existing command, e.g. nestat, when root meant to type netstat. The nestat command would then silently grant the user root privileges (one way is to bless a command as root setuid), and then exit with "nestat not found". Nothing would seem amiss.
|
|
||||
|
And what about the root who wanted to type
Code:
ls -d Code:
lsd This . is thought to be dangerous allready for at least 30 years.
__________________
Henk van Velden |
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|