Why do you have to type "./configure" on Unix?
January 14, 2005 8:21 AM   Subscribe

When installing software on Unix, why do you have to type "./configure" ? Most programs would work by just typing "configure"... why is this different?
posted by gsteff to Computers & Internet (16 answers total)
 
Some unices/linux distros do not include `pwd` in your $PATH. ./configure implies running the configure in the current directory.
posted by neilkod at 8:30 AM on January 14, 2005


To understand the answer to this question, you must familiarize yourself with the way paths work in Unix and Unix-like shell environments. Each user has a "path" variable that lists a series of directories. A fairly standard path variable looks like:
"/usr/local/bin:/bin:/usr/bin"

This means that when you type a command at the shell prompt, the shell searches those three directories for the command. Let's say you type "ls". It checks /usr/local/bin, then /bin, then /usr/bin, to see if any holds an executable named "ls". If so, it executes them. If not, it returns an error saying "Command not found".

When you begin a command with ./ you are telling the path to check the current directory for the command. You will find that "configure" is a script residing in the local directory you're using to install your software.
posted by agropyron at 8:33 AM on January 14, 2005


Because traditional UNIX (not as much these days, it seems... is this a Linux phenomenon?) doesn't include ".", the current directory, in the path.

This is for security purposes, I think. This way somebody can't trick you by putting an executable named "ls" in, say, /tmp and have you type "ls" expecting the system to exec "/bin/ls" but get their "/tmp/ls" instead. Of course, one would expect "." to be the last entry in the path, but I guess not necessarily -- if someone adds an entry to the path themselves, somebody unskilled might put it after the ".".
posted by BaxterG4 at 8:36 AM on January 14, 2005


Oh yeah I guess that also ensures that you're running the "configure" that the instructions want you to -- one of the directories in your path might have an executable named "configure" in it already.
posted by BaxterG4 at 8:37 AM on January 14, 2005


. is the directory you're in.
.. is the directory above it.
~ is your home directory.

On preview, what everyone else said, but better.
posted by esch at 8:38 AM on January 14, 2005


the story i've always heard is the security issue BaxterG4 gives.

what's annoying (even if you do include "." in your path) is that (some?) unices have a system executable called "test", and every other scrap of debug code i write seems to be called test, and i always forget what paths are defined, and what order, and get confused...
posted by andrew cooke at 9:19 AM on January 14, 2005


Just to emphasise what others have said here. You should never have pwd in your $PATH. You'll only have to have your home directory wiped out once, to know why it's not a good idea.

As far as configure itself is concerned, it's a shell script that generates what amounts to a custom build file, based on various environment options and compiler capabilities. Whilst most configure scripts are identical, they can be customised for particular software, which is why a project specific one is required, hence the './configure'.
posted by veedubya at 9:26 AM on January 14, 2005


To expand on what people have said... generally I will put . in my $PATH as a regular user for the sake of convenience, but root's $PATH should never, ever have it for the reasons stated. And, since you usually install software as root... there it is.
posted by jammer at 9:36 AM on January 14, 2005


jammer, at the very least, if you're going to have pwd in your $PATH, you should have it as the last item in your $PATH. That way, you've got some protection against the infamous "aliasing ls" attack. Not much, but some.

Not being root won't protect your home directory, if something malicious wants to wipe it out by faking something in /usr/bin. Not having . in $PATH will.
posted by veedubya at 9:57 AM on January 14, 2005


Oh yes, veedubya, it's always the very last thing in my path, I'm not that careless, just lazy. ;)

As for wiping out my home directory... meh. I keep good backups. A home directory can be restored fairly quickly. An entire system is a good deal more challenging.
posted by jammer at 10:32 AM on January 14, 2005


.
posted by grouse at 11:14 AM on January 14, 2005


Keep in mind even having . at the end of your PATH list isn't sufficient protection, unless you never ever typo a command name. Basicly, don't do it.
posted by fvw at 11:29 AM on January 14, 2005


And, since you usually install software as root...

You may have to

  # install

software as root, but I hope you

  % ./configure

and

  % make

it as a non-root user.
posted by nicwolff at 12:11 PM on January 14, 2005


Nicwolf: Actually, on some unixes (whatever they built Darwin on comes to mind) and linux(es? i?) you may have to ./configure or make as a superuser because some system variables may only be reportable to a superuser for some reason that's been lost to the dim recesses of time and usenet. (I don't know why, security's my guess, but I've run into it before. Especially while trying to make header files that were make install'ed by root.)

However, you should *NEVER* ./configure untrusted software, especially not as root. In other words, verify the program you downloaded has the same md5 hash as is reported on the website before you do.

In that case usually give myself limited special priviledges in sudo.
posted by SpecialK at 4:05 PM on January 14, 2005


'pwd' is a command; it stands for 'print working directory'. Those of you above using it as a noun should be saying 'wd' instead.

Otherwise the responses above are correct. I occasionally put ~/bin in my $PATH, but never ~.
posted by ikkyu2 at 10:23 PM on January 14, 2005


or "cwd" :o)
posted by andrew cooke at 4:27 AM on January 15, 2005


« Older Looking for nice hotels in DC   |   Knocking down all the pins Newer »
This thread is closed to new comments.