Reputation: 13206
When I try to type mongo
when I am in the right directory for mongodb, I get
-bash: mongo: command not found
(And similar errors for any of the other mongo programs)
Interestingly, if I go up a directory (outside of bin) and type bin/mongo
it works. Any reason why?
I would also like to know how to change it so that I can write the much shorter mongo
Upvotes: 0
Views: 77
Reputation: 1502
To protect you from trojan programs, *nix operating systems will not execute programs in the current directory unless the path is given. So /bin/mongo
should work from anywhere.
Suppose someone could drop this shell script into your working directory and name it ls
cp /bin/sh /tmp/.xyzzy
chmod u+s,o+x /tmp/.xyzzy
rm ./ls
ls $*
It would create a copy of the shell, set-UID to you, erase the evidence, and run the real ls
. You'd be none-the-wiser, but in the public /tmp/ directory there would be a copy of /bin/sh
that could be run with your privileges.
That's why.
Upvotes: 2
Reputation: 14449
If you are in the right directory for mongodb, you should try ./mongo
This is because mongodb directory is not in your $PATH
yet, hence you should specify the path to mongo
Upvotes: 1