“nano”不被识别为内部或外部命令

目录

‘nano’ is not recognized as an internal or external command

  1. “nano”不被识别为内部或外部命令
  2. 纳米:找不到命令

‘nano’ 不被识别为内部或外部命令

nano在没有安装的Windows上运行命令时出现“’nano’不是内部或外部命令、可运行程序或批处理文件”的错误nano

要解决该错误,请nano使用 Chocolatey 安装。

nano 不被识别为内部或外部命令

如果你
安装了
Chocolatey

  1. 单击搜索栏并键入 PowerShell。

  2. 右键单击 PowerShell 应用程序,然后单击“以管理员身份运行”。

以管理员身份运行 powershell

  1. 运行以下命令进行安装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.

以管理员身份运行 powershell

  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安装巧克力

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

Windows 验证已安装巧克力

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.

巧克力安装纳米

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

cmd
nano --version

纳米印刷版

You can create a new file with the following command.

cmd
nano example.txt

使用 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 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.

shell
sudo apt update sudo apt-get install nano

sudo apt 安装 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 获取 nano 版本

You can create a new file with the following command.

cmd
nano example.txt

bash 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 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: