I want to create a symbolic link for vi to see this program when calling from console run vim:

ln -s /usr/bin/vi /usr/bin/vim`
ln: failure to create symbolic link «/ usr / bin / vim»: The file already exists

how can I do it so I saw it point to vim

  • ls -l /usr/bin/vim show you what? It seems that this link ALREADY exists or it is a specific no compat link to vi. – user34720 Mar 22 at 16:30


You can force to remove the destination file using -f (Test before changing anything!)

ln -sf /usr/bin/vi /usr/bin/vim

Works for me!


[root@vvek-workstation grep]# ln -ss ./vi ./vim 
ln: failed to create symbolic link ‘./vim’: File exists
[root@vvek-workstation grep]# ln -sf ./vi ./vim 
[root@vvek-workstation grep]# ls -lart
total 0
drwxr-xr-x. 9 root root 228 Mar 20 15:20 ..
-rw-r--r--  1 root root   0 Mar 20 16:00 vi
lrwxrwxrwx  1 root root   4 Mar 20 16:00 vim -> ./vi
drwxr-xr-x  2 root root  27 Mar 20 16:00 .
  • and to remove the symbolic link without deleting vim ?? – ortiga Mar 20 at 20:10
  • ln -sf /usr/bin/vim /usr/bin/vi perfect but i need to remove the symbolic link without deleting vim ?? – ortiga Mar 20 at 20:21

Given your original tag of CentOS, I'll assume that you have an /etc/profile.d/vim.sh file that sets up an alias:

alias vi >/dev/null 2>&1 || alias vi=vim

If you want to run vi when you enter vim, I'd suggest adding to your own ~/.bashrc:

unalias vi
alias vim=vi

Yes, if you already have /usr/bin/vim, you cannot have another file of the same name in that directory. However, /usr/bin is (usually) not the only location checked for executables.

Run echo $PATH to see the list of directories that is checked, left to right. Hopefully, you'll have locations like /home/(username)/bin or /usr/local/bin in there. In that case,

ln -s /usr/bin/vi /usr/local/bin/vim 

will override the default vim for all users. (They can still call /usr/bin/vim to get the original.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.