[uClibc] Why do I have to add ./ to execute programs

Bennett Todd bet at rahul.net
Mon Jun 21 17:56:49 UTC 2004


2004-06-21T01:30:19 Hoffknecht:
> Pretty much all programs require that I add ./ in front of the
> executable in the current directory, such as ./gdb. Why is that?

Because your environment isn't properly set up.

A normally set up Unix system (Linux is no different) has the
executables in a small assortment of standard places, and the PATH
set up to point to them. For many Linux systems this command
sequence will fix things, and you can put it in your .profile:

	PATH=/usr/bin:/bin:/usr/local/bin:/usr/sbin:/sbin:/usr/local/sbin:/usr/X11R6/bin:$HOME/bin
	export PATH

That list of dirs can be shorter on most systems, and can be
re-ordered to taste. E.g. mine is

	PATH=/sbin:/usr/sbin:/bin:/usr/bin:$HOME/bin

I recommend against adding "." to your PATH; that approach (a)
leaves you having to change directories to tell your shell where to
find things, and (b) leaves you vulnerable to trojan horses if you
ever change to a dir that anyone else can write.

> The shell commands don't require it ....

because they are built in to the shell, and so don't require it to
search the PATH to find the executables.

-Bennett
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/uclibc/attachments/20040621/a008df3c/attachment-0002.pgp 


More information about the uClibc mailing list