Reputation: 2121
I was trying to add the mvim shell script to /usr/local/bin form bash as per this question and everything seemed to work; however, I am still getting "command not found" whenever I try to execute the script.
From the directory where my mvim file is (Downloads), I typed:
sudo cp -v mvim /usr/local/bin
and I get output:
mvim -> /usr/local/bin
and then it doesn't work whether I type mvim
or mvim -v
I've never added something to my $PATH before, but even after looking up a number of tutorials on how it is done, I can't seem to get mvim
to work as a terminal command.
EDIT:
echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
and
ls -l mvim
-rwxr-xr-x ...
and
ls -l /usr/local/bin
-rwxr-xr-x ...
Upvotes: -1
Views: 1375
Reputation: 121809
This is what you posted:
mvim -> /usr/local/bin
I believe that's wrong. It looks like "mvim" is a symbolic link that points to the directory /usr/local/bin.
If so, this is not what you want!
Please do the following:
Open a terminal (command-line) window.
"cd" to the directory with your original "mvim" (the one you tried to copy to /usr/localbin)
Cut/paste:
a) the directory name
b) ls -l mvim
c) echo $PATH
The "echo $PATH" is also important.
Upvotes: -1
Reputation: 3687
If you run sudo cp -v mvim /usr/local/bin
and the /usr/local/bin
folder does not exist, cp will copy mvim
to the /usr/local/
folder and name it bin
.
You need to first create the folder with sudo mkdir -p /usr/local/bin
. Then, you can copy mvim
with the previous cp
command.
Have you made sure that /usr/local/bin/mvim
has the executable flag set? Try ls -l /usr/local/bin/mvim
and if the result starts with -rw-r--r--
, then mvim is not executable.
You then need to run sudo chmod +x /usr/local/bin/mvim
. If you now run the previous ls
command again, the result should start with -rwxr-xr-x
. The x
means that the file is now executable by its owner, members of its group, and all other users too.
Have you made sure that /usr/local/bin
is part of your PATH
variable?
Try echo $PATH
and if the output does not contain /usr/local/bin
, then the shell will not look for commands there. You then need to run export PATH=$PATH:/usr/local/bin
Upvotes: 7
Reputation: 206861
Either start a new shell, or type:
hash -r
so that the shell re-inspects the directories in the $PATH
. (It caches the contents for efficiency, you need to reload that cache when you add things to directories in your path.)
Upvotes: 1
Reputation: 64613
Check:
echo $PATH
)Upvotes: 1