'nano' is not recognized as an internal or external command

avatar
Borislav Hadzhiev

Last updated: Apr 4, 2024
4 min

banner

# Table of Contents

  1. 'nano' is not recognized as an internal or external command
  2. nano: command not found

# 'nano' is not recognized as an internal or external command

The error "'nano' is not recognized as an internal or external command, operable program or batch file" occurs when we run the nano command on Windows without having nano installed.

To solve the error, install nano using Chocolatey.

nano is not recognized as internal or external command

If you have Chocolatey installed:

  1. Click on the Search bar and type PowerShell.

  2. Right-click on the PowerShell application and click "Run as administrator".

run powershell as administrator

  1. Run the following command to install nano.
PowerShell
choco install nano -y
If you don't have Chocolatey installed, you have to install it first.

To install Chocolatey:

  1. Open PowerShell as an administrator.

run powershell as administrator

  1. Run the following command.
PowerShell
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

windows install chocolatey

  1. Wait for the command to complete.
  2. Type choco to make sure Chocolatey is installed.

windows verify chocolatey installed

Now that you have Chocolatey installed, run the following command to install nano.

PowerShell
choco install nano -y

Note that your shell should still be run using elevated permissions.

chocolatey install nano

Click on the Search bar, type "cmd" and start the Command Prompt application.

cmd
nano --version

nano print version

You can create a new file with the following command.

cmd
nano example.txt

create file using nano

The most common keyboard shortcuts you will have to use are:

  • Ctrl+S - Save the current file.
  • Ctrl+X - Close the buffer and exit from nano.

If you don't want to save the changes you've made to the file:

  1. Press Ctrl+X and you will be prompted if you want to save the modified buffer.
  2. Press n to exit from nano without saving the file.

Here are some useful nano keyboard shortcuts.

Keyboard shortcutDescription
Ctrl + SSave the current file.
Ctrl + XClose the buffer and exit from nano
Ctrl + CCancel or report the current cursor position
Alt + UUndo last action.
Alt + ERedo last undone action.
Ctrl + KCut the current line into the cut buffer.
Alt + 6Copy the current line into the cut buffer.
Ctrl + UPaste the contents of the cut buffer.
Alt + DelDelete the current line.

# nano: command not found error in bash and zsh

If you get the nano command not found error, you have to issue the sudo apt install nano command.

The error occurs when you try to use the nano command in bash or zsh without having the editor installed.

shell
sudo apt update sudo apt-get install nano

sudo apt install nano

If you use Windows Subsystem for Linux, open CMD and start bash before installing nano.

cmd
# ๐Ÿ‘‡๏ธ Start bash bash # ๐Ÿ‘‡๏ธ Fetch data from repositories sudo apt update # ๐Ÿ‘‡๏ธ Install nano sudo apt-get install nano

Issue the nano --version command to verify that the editor is installed.

cmd
nano --version

bash get nano version

You can create a new file with the following command.

cmd
nano example.txt

bash nano create file

The most common keyboard shortcuts you will have to use are:

  • Ctrl+S - Save the current file.
  • Ctrl+X - Close the buffer and exit from nano.

If you don't want to save the changes you've made to the file:

  1. Press Ctrl+X and you will be prompted if you want to save the modified buffer.
  2. Press n to exit from nano without saving the file.

Here are some useful nano keyboard shortcuts.

Keyboard shortcutDescription
Ctrl + SSave the current file.
Ctrl + XClose the buffer and exit from nano
Ctrl + CCancel or report the current cursor position
Alt + UUndo last action.
Alt + ERedo last undone action.
Ctrl + KCut the current line into the cut buffer.
Alt + 6Copy the current line into the cut buffer.
Ctrl + UPaste the contents of the cut buffer.
Alt + DelDelete the current line.

I've also written an article on how to show the line numbers in the Nano text editor.

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.

Copyright ยฉ 2024 Borislav Hadzhiev