目录
‘nano’ is not recognized as an internal or external command
‘nano’ 不被识别为内部或外部命令
nano
在没有安装的Windows上运行命令时出现“’nano’不是内部或外部命令、可运行程序或批处理文件”的错误nano
。
要解决该错误,请nano
使用 Chocolatey 安装。
如果你
安装了Chocolatey
:
-
单击搜索栏并键入 PowerShell。
-
右键单击 PowerShell 应用程序,然后单击“以管理员身份运行”。
- 运行以下命令进行安装
nano
。
choco install nano -y
To install Chocolatey:
- Open PowerShell as an administrator.
- Run the following command.
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'))
- Wait for the command to complete.
- Type
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 fromnano
.
If you don’t want to save the changes you’ve made to the file:
- Press
Ctrl+X
and you will be prompted if you want to save the modified
buffer. - Press
n
to exit fromnano
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. |
# 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.
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 fromnano
.
If you don’t want to save the changes you’ve made to the file:
- Press
Ctrl+X
and you will be prompted if you want to save the modified
buffer. - Press
n
to exit fromnano
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.
# Additional Resources
You can learn more about the related topics by checking out the following
tutorials:
- ‘wget’ is not recognized as an internal or external command
- ‘sudo’ is not recognized as an internal or external command
- Windows Equivalent of the ‘ls’, ‘which’ and ‘ln’ commands
- The Windows equivalent of the Unix ‘tee’ command
- Windows 等同于 Unix 的“pwd”命令
- Windows 相当于 Unix 的“tail”命令
- “vim”不被识别为内部或外部命令
- gcc 不被识别为内部或外部命令