LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 10-28-2003, 04:11 PM   #1
cmargiol
LQ Newbie
 
Registered: Oct 2003
Posts: 2

Rep: Reputation: 0
executing programs?!?


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
 
Old 10-28-2003, 04:15 PM   #2
stickman
Senior Member
 
Registered: Sep 2002
Location: Nashville, TN
Posts: 1,552

Rep: Reputation: 53
You have to add the "./" because the current directory is not in your PATH. Append that directory to you PATH variable.
 
Old 10-28-2003, 05:21 PM   #3
RockmanExe
Member
 
Registered: Aug 2003
Distribution: Mandriva, Slackware
Posts: 265

Rep: Reputation: 30
Quote:
Originally posted by stickman
You have to add the "./" because the current directory is not in your PATH. Append that directory to you PATH variable.
Which means ....???
 
Old 10-29-2003, 06:31 AM   #4
cmargiol
LQ Newbie
 
Registered: Oct 2003
Posts: 2

Original Poster
Rep: Reputation: 0
Well, I know it is not in my path. That is the point actually. Since I am in that directory, why does it nead to be in my path???
 
Old 10-29-2003, 07:04 AM   #5
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
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.

Just add the dot. *g*

Last edited by slakmagik; 10-29-2003 at 07:09 AM.
 
Old 10-29-2003, 08:37 AM   #6
stickman
Senior Member
 
Registered: Sep 2002
Location: Nashville, TN
Posts: 1,552

Rep: Reputation: 53
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.
 
Old 10-29-2003, 08:55 AM   #7
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
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.
 
Old 10-29-2003, 01:40 PM   #8
stickman
Senior Member
 
Registered: Sep 2002
Location: Nashville, TN
Posts: 1,552

Rep: Reputation: 53
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.
 
Old 10-29-2003, 02:38 PM   #9
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem executing java programs nro Programming 2 08-28-2004 01:09 AM
Executing X-Programs remotely frankieboy Linux - General 3 10-08-2003 02:31 AM
executing programs with arguments ? shaneblyth Mandriva 10 09-27-2003 08:01 PM
Executing programs from a terminal window subzero0 Linux - General 0 09-26-2003 12:36 PM
Executing Perl Programs 1huskerfan Programming 3 01-06-2002 07:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration