I have recently upgraded to Fedora 33 (Linux 5.9.16-200) on my machine. I am running vim-enhanced version 8.2. When I type sudo vim (or even sudo vi) in order to edit files with admin privilege, I get the following error.

sudo: __vi_internal_vim_alias: command not found

I am not sure what is causing this. Vim loads fine without the sudo. Could you please tell me how to troubleshoot this? Thank you.

Update: Upon executing which vim, I get the following result.

alias vim='__vi_internal_vim_alias'
    __vi_internal_vim_alias ()
        ( test -f /usr/bin/vim && exec /usr/bin/vim "$@";
        test -f /usr/bin/vi && exec /usr/bin/vi "$@" )

I am not sure what did this and where. Maybe it's a Fedora 33 thing. Given the above information, what do you suggest is a permanent fix?

  • I'm wondering if you get the same error executing sudo vim --clean. Is there a /root/.vimrc or /root/.vim/vimrc or /root/.exrc? – rickhg12hs Jan 7 at 19:29
  • Yes, same error for that. No, those files do not exist. – Nanashi No Gombe Jan 7 at 19:31
  • 1
    How about sudo \vim? – rickhg12hs Jan 7 at 19:35
  • Your user vim must be, or try to execute, a script, a link, an alias, or even an executable that is not in root's PATH. There are probably some other failure modes too. I wish I could find the POSIX standard to reference all the details, but a POSIX shell (not just bash) must not do alias expansion if the commandline begins with a backslash. Please refer to the actual standard/documentation for the details (I don't know them.), I usually just try the \command trick when things seem wacky (usually encountered when asked to use another user's "customized" shell). – rickhg12hs Jan 7 at 19:57
  • What do you get for env -i HOME="$HOME" bash --login --norc -c 'which vim'? – rickhg12hs Jan 7 at 20:34

As @scy mentioned unalias-ing the vi and vim is a workaround solution for keeping the sudo="sudo " alias so it can be used with other aliases.

Expanding his/her answer for the different shells:

ZSH Shell: Add to the .zshrc file (of the user you want to be affected by the changes)

  • located at:

For Fedora 33 Workstation(or Server or another non-atomic OS Distro): /home/$USER/.zshrc

For Fedora CoreOS 33.x (or Silverblue 33 or other similar atomic OS Distro): /var/home/$USER/.zshrc

  • the following lines of code:
[ "$(type -w vi)" = 'vi: alias' ] && unalias vi
[ "$(type -w vim)" = 'vim: alias' ] && unalias vim

BASH Shell: Add to the .bashrc file (of the user you want to be affected by the changes)

  • located at the same locations, respective to the OS/Distro specific location for the $USER 's home directory (check the directions for Fedora Workstation, etc...)
  • the following code:
[ "$(type -t vi)" = 'alias' ] && unalias vi
[ "$(type -t vim)" = 'alias' ] && unalias vim

P.S. Concerning ZSH Shell, this solution can resolve similar problems with other CLI applications that are in a similar initialization situation. For example: mc (Midnight Commander). Meanwhile, mc will not have any such problem in BASH Shell.

  • It also affects Fedora 32. And this solution works. Thank you and thanks to @scy – erik Feb 1 at 12:05

Hitting the same issue on Fedora 33. This seems due to having an alias defined for sudo in my environment:

$ alias sudo
alias sudo='\sudo '

Due to this, somehow bash resolves aliases passed as arguments to sudo alias, as shown in the example below:

$ alias foo='echo foo'
$ sudo foo

I would have expected to have this instead:

$ sudo foo
$ sudo: foo: command not found

Deleting this alias worked for me. This alias was created by /usr/local/bin/alias.sh, part of synth-shell project (https://github.com/andresgongora/synth-shell)

  • 2
    Really useful first post, thanks! ;) I’ve experienced the issue as well and indeed removing the sudo alias fixes it. However, if you’d like to keep that sudo='\sudo ' alias (since it allows you to use aliases from your .bashrc together with sudo), you could remove Fedora’s vi/vim aliases instead. I’ve added [ "$(type -t vi)" = 'alias' ] && unalias vi and [ "$(type -t vim)" = 'alias' ] && unalias vim to my .bashrc as a workaround for this issue. – scy Jan 12 at 11:50
  • When I do alias sudo, I get alias sudo='sudo '. Also, I don't have the /usr/local/bin/alias.sh file. – Nanashi No Gombe Jan 12 at 14:04
  • As stated in the answer and my comment, you can either remove that sudo alias (it’s probably somewhere in your ~/.bashrc or ~/.bash_profile) or remove the vi and vim aliases. – scy Jan 20 at 14:24

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.