[Solved] “bash: vim: command not found” Error

A Complete Guide for Beginners Enroll Course Now

The “vim: command not found” error in Bash indicates that the “vim” command is either not installed or inaccessible. To fix this error, run:

sudo apt install -y vim

This error signifies difficulty in accessing the Vim text editor within the Bash environment. It typically arises when Vim is not installed or not included in the system’s PATH. So, installing Vim and configuring the system environment solves the problem in most cases. Let’s see all the possible solutions to this error.

Reasons for “vim” Command Not Found Error

Some common reasons for “vim” command not found error are:

  • Incorrect Spelling: An error in command spelling raises the “command not found” error in Bash.
  • Vim not Installed: If you are unable to use the “vim” command, it could be that your system does not have Vim installed.
  • Incorrect Installation Path: The PATH on your system may not contain Vim.
  • Inadequate Permissions: Vm might not have the authorization it needs to function.
  • Sudo Configuration: If encountering the error with sudo, it might be due to the secure_path setting in the “sudoers” file.

2 Methods to Solve “bash: vim: command not found”

Follow the below methods to solve the vim command not found error in Bash:

1. Install “vim”

Most of the time, an incorrect installation of Vim on your system causes the “bash: vim: command not found” error. In this instance, APT in Ubuntu, YUM in RedHat, and Pacman in Arch Linux can install “vim” on your system with all its dependencies. To do that, follow the steps:

  1. Press CTRL+ALT+T to open the terminal.
  2. Run the command to install vim in Ubuntu:
    sudo apt install -y vim

    installing vim using apt

  3. Execute vim to verify the installation.vim interface

Now, the vim command is executed successfully and opened the Vim text editor.

2. Set “vim” PATH Variable

A prevalent reason behind the “vim command not found” is Vim is not present in your system PATH environment variables. To set the PATH variable for vim, follow the steps below:

  1. Press CTRL+ALT+T to open the terminal.
  2. Use which command to check the current path of Vim:
    which vim

    executing which vim

  3. Open bashrc file using:
    nano ~/.bashrc
  4. Now, replace <path to vim> in export PATH=$PATH:<path to vim> code with the which command’s output and paste it at the end of the file. For example:
    export PATH=$PATH:/usr/bin/vim

    adding vim path variable to bashrc file

  5. Press CTRL+S to save, and CTRL+X to exit.
  6. Then, execute the .bashrc file using:
    source ~/.bashrc
  7. Now you can check running a vim command. For example:
    vim –version

    executing bashrc file and checking vim version

After adding the path, the vim command ran without raising any error.


In conclusion, resolving the “bash: vim: command not found” issue involves ensuring the installation of Vim and configuring the system’s PATH appropriately. Applying these solutions allows you to seamlessly access Vim commands within the Bash environment and unlock Vim’s powerful document editing capabilities.

People Also Ask

How to fix vim command not found in CentOS?

To fix the “vim: command not found” in CentOS, execute sudo dnf install vim. Subsequently, to update the shell profile, open .bashrc file using nano ~/.bashrc and add export PATH=$PATH:/usr/bin/vim. After adding the line, either restart the terminal or run source ~/.bashrc. Now, you can run vim command.

How to fix vim command not found in RHEL?

To fix the “vim command not found” issue in Red Hat Enterprise Linux (RHEL), first, run sudo yum install vim to install it. Then open the .bashrc file and add export PATH=$PATH:/usr/bin/vim at the end. Finally, run source ~/.bashrc to apply changes. Verify the installation by typing vim in the terminal to ensure Vim is now accessible.

How to fix vim command not found in Arch Linux?

To fix the “vim: command not found” in Arch Linux, execute sudo pacman -S install vim. Then,  open .bashrc file and add export PATH=$PATH:/usr/bin/vim. After adding the line, either restart the terminal or run source ~/.bashrc. Now, you can run vim command.

How to solve “sudo: vim: command not found”?

If you’re getting the “sudo: vim: command not found” error, it means that the vim text editor is not installed on your system, or it’s not in the system’s PATH for the user running the sudo command. To solve this error, install vim in your system using the package manager. If vim is installed but you still get the error, open ./bashrc file and add the line below:

export PATH=$PATH:[path to vim]

To get the [path to vim], run which vim command.

Related Articles

<< Go Back to [Solved] “bash: command not found” Error | Bash Error Handling and Debugging | Bash Scripting Tutorial

Rate this post
Ashikur Rahman

Hello, I’m Ashikur Rahman, currently working as a Linux Content Developer Executive at SOFTEKO. I have completed my graduation in Computer Science and Engineering from Khulna University of Engineering & Technology (KUET). Also, I’m pursuing my master’s in the same department at Bangladesh University of Engineering & Technology (BUET). I like to learn new technologies, contribute, and share those with others. Here my goal is to provide beneficial and user-friendly articles on Linux distribution for everyone. Read Full Bio

Leave a Comment