Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I've only been using linux for a couple of days (red hat 9). I 've compiled a very simple program (using ADA95) and tried to run the executable. Opened a terminal window changed the current directory to the directory that contains the program and typed the name of the program.
It won't run unless I write the full path. A shorter way would be "./program" but since the current directory is the directory that contains the program, why do I still have to write the path? Am I missing something or is it just the way it goes?
thx in advance
Your current working directory is different from your list of executable directories. It still needs to be on the path for you to execute anything from it.
I would add
PATH="$PATH:.";export PATH
to ~/.bash_profile (which ~/.bashrc is symlinked to, in my case) though there are various ways to do it.
-- In DOS, your current directory is on your path automatically, but in Linux, due to convoluted security concerns regarding substituting files with trojans on non-root directories in which root might, for some reason, type a command and yet somehow not have it get intercepted higher up the path order, some distros cut even regular users off from the current working directory. Unix paranoia, in other words.
Adding "." in your PATH so that the current directory is always in your PATH is a security concern. It opens you up to running trojans, etc. It's especially dangerous when it is appended to the front of the PATH statement. If this is a program that will be run fairly regularly, move it to a standard location or add that single directory to the PATH.
Exactly - the front of the path. But if you put it on the end, what the hell good does it do to put a trojan 'less' somewhere when the /usr/bin/less is going to get run anyway? And anybody who wastes time planting misnamed trojan executables like 'lesd' in random directories of regular users in the hopes that they'll make the exact same typo that the trojan happens to be named *while* they happen to be in that same directory... it's ridiculous. That said, all my files and directories are chmod 600 or 700 and I do have a directory for frequently used executables but I still have a damn dot on the end of my path and, oddly, I'm not too worried about that. It's as bad as the permissions on my floppy drive. Oh $#!^, somebody cracked my machine and issued 'mount /mnt/floppy'! Thank goodness 'only root can do that'. And thank goodness they didn't have anything better to do after having cracked my machine than mount and unmount my floppies.
Note, I'm not yelling at you, stickman - just yelling about certain *nix habits.
It's not so much a chance that someone will make the same typo, but that someone will attempt to use an command or alias that's not available on that system. Again, the dot in the PATH is more of a concern on multiuser systems where people work in many different directories.
As for "certain *nix habits", you'd be surprised what stupid things come up in an audit, especially when it's being done by those nontechnical accountant-types.
Ah, I see. Slack user on a RH box typing xwmconfig without thinking about it or a mandrake user on a Slack box typing foodrake or something. I can actually see something like that happening. And, as I say, no sense in it being on root's path or being anywhere but the end of user's path but, for a home user on his own box, I'd rate the risks as pretty minimal. Still, I do tend to put stuff in a directory or put symlinks there and, even when you do something like './configure' it's a good idea to specify the current directory so I suppose the benefits are pretty minimal, too. I may try taking it off my path for the heck of it - see if I even notice the difference. Slack configures regular users to have the current directory on the end of their path by default.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.