Last updated: Apr 4, 2024
Reading timeยท4 min
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.
If you have Chocolatey installed:
Click on the Search bar and type PowerShell.
Right-click on the PowerShell application and click "Run as administrator".
nano
.choco install nano -y
To install Chocolatey:
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'))
choco
to make sure Chocolatey is installed.Now that you have Chocolatey installed, run the following command to install
nano
.
choco install nano -y
Note that your shell should still be run using elevated permissions.
Click on the Search bar, type "cmd" and start the Command Prompt application.
nano --version
You can create a new file with the following command.
nano example.txt
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:
Ctrl+X
and you will be prompted if you want to save the modified
buffer.n
to exit from nano
without saving the file.Here are some useful nano
keyboard shortcuts.
Keyboard shortcut | Description |
---|---|
Ctrl + S | Save the current file. |
Ctrl + X | Close the buffer and exit from nano |
Ctrl + C | Cancel or report the current cursor position |
Alt + U | Undo last action. |
Alt + E | Redo last undone action. |
Ctrl + K | Cut the current line into the cut buffer. |
Alt + 6 | Copy the current line into the cut buffer. |
Ctrl + U | Paste the contents of the cut buffer. |
Alt + Del | Delete the current line. |
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.
sudo apt update sudo apt-get install nano
If you use Windows Subsystem for Linux, open CMD and start bash
before
installing nano
.
# ๐๏ธ 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.
nano --version
You can create a new file with the following command.
nano example.txt
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:
Ctrl+X
and you will be prompted if you want to save the modified
buffer.n
to exit from nano
without saving the file.Here are some useful nano
keyboard shortcuts.
Keyboard shortcut | Description |
---|---|
Ctrl + S | Save the current file. |
Ctrl + X | Close the buffer and exit from nano |
Ctrl + C | Cancel or report the current cursor position |
Alt + U | Undo last action. |
Alt + E | Redo last undone action. |
Ctrl + K | Cut the current line into the cut buffer. |
Alt + 6 | Copy the current line into the cut buffer. |
Ctrl + U | Paste the contents of the cut buffer. |
Alt + Del | Delete the current line. |
I've also written an article on how to show the line numbers in the Nano text editor.
You can learn more about the related topics by checking out the following tutorials: