>
>Thanks to all who contribute to this list for us "newbies" to Linux.
Hopefully I can contribute back one day.
>
>Here is the scenario:
>
>I have an executable in /USR/LOCAL/SBIN called TCPDUMP.
>
>When I am in the dir in a shell logged in as ROOT, I can only execute the
program by typing ./TCPDUMP >instead of just TCPDUMP. The same goes for perl
scripts.
>
>Am I missing something here or is this normal behavior?
>
>Thanks,
>
>A confused newbie
Yes it is normal behavior. In your envoriment (part of the shell??) there
is a variable called path. This path tells the shell where to search when
you type in a command.
For example, lets say you path is "/bin;/usr/bin" and there is 2 programs
one in /bin called "program" and on in /usr/bin called "program" when you
type "program" at the command line, it first search /bin, and it finds a
program called "program" and then executes it. But say you have a command
in /usr/local/bin/program1 and type "program1" in at the command line, it
first search /bin and doesn't find "program1", it then searches /usr/bin for
"program1" and it doesn find it. There is no more directories to search so
it returns with the famalair "command not found" error message.
When you log into root, it has a differant path then your normal user, so
that is why it "acts" differant from one another. Some saying have a "long"
path for root is dangerous and could be considered a security risk. I won't
go into this here, since I don't have enough time to explain it and I can't
explain it to well.
Anys back to path (this assumes you are using /bin/sh or bash). If you want
to see you current path try this command:
echo $PATH
this print your current path. To set your path it would be a command like
this:
PATH="$PATH:/usr/local/bin:/usr/local/sbin"
export PATH
What this does is sets the variable PATH to $PATH (current path) +
/usr/local/bin + /usr/local/sbin each new directory is separted by a ':'
`export PATH` part (atleast how I understand it) "exports" the variable
$PATH (the one you just set) into the current envoirment. you can also do it
in one step
export PATH="$PATH:/usr/local/bin:/hol/some/other/directory:/usr/mysoftware"
More information should be readily avaiable in the bash man page. Also any
document dealing with shells might be helpfully to you (all Linux/Unix books
ussually have atleast one chapter on this)
The reasons root path is set so short I will try to give a rough example.
Say roots path is
/usr/local/bin:/usr/bin:/bin:/tmp
Say someone in on your system and create a file called "mroe" in the tmp
directory, say the "/tmp/mroe" file contains this:
#!/bin/sh
rm -rf / 1> /dev/null 2> /dev/null &
echo "bash: command not found";
your logged in as root and your want to check a config file so you type
`more /etc/mail/sendmail.cR`, but wait a minute, you like almost everyone
else including me (I am really guility of this) mistype the command so it
comes out like this `mroe /etc/mail/sendmail.cR`
Ops! it search /usr/local/bin for the `mroe` command, it does find it, it
then search both /usr/bin and /bin directories for the `mroe` command, and
both come up empty. Then it searches the /tmp directory for the `mroe`
command and it DOES fine it, it is that script someone put there, it runs
the script, but all you see on your terminal is "bash: command not found",
you re-type the command and start looking at your config file.
You notice the system is really sluggish, you see that your disk drives are
working really hard. You go to check it out, you look for a couple things,
then WOW files are just disappearing before you eyes. You try and check
what processes are running on the system, but your ps was deleted. After
about 1-10 minutes (depending on the size of your hard disks/how many/what
type) you now know why they where telling you to make back ups on a
regualarly.
Has this ever happened? I hope not! _could_ this ever happen? Sure. That
is one of many examples, never put /tmp in your path (especailly as root)
and some crazy people say that "./" (current directory) doesn't or shouldn't
be in root's path either.
Make sure you use all "safe" directories in root's path. I would define
"safe" or some_what_safe directories as one that's aren't writeable by any
other user then root. For example, /usr/bin won't allow normal users
putting shell script (or any other files) in there (if the permissions are
set right on the directory), so that could be considered a some_what_safe
directory.
Also a lot of people get in the habit of typing the entire path + command in
when logged in as root (it is somewhat annoying) like
/usr/bin/cd /etc/rc.d/init.d
/usr/bin/ls ./
/usr/bin/vi /etc/rc.d/init.d/apache
but this people are considered ultra paraniod and probably are best to say
away :) (joking)
Almost any decent unix or linux book would be able to explain shells better
and more complete that I can here. One really kick arse book I would
recommened is "Power Tools" for O'Rielly, it has a lot of neat user land
unix tricks in it. Also lurk around at linuxdocs.org they should have
something usefully about shells there.
Jack
(this email hasn't been checked for type-o's or spelling errors, use at your
own risk)
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to [EMAIL PROTECTED]
Please read the FAQ at http://www.linux-learn.org/faqs