Linux debian установка nano

How To Install Nano Text Editor on Debian 11

In this tutorial, we will show you how to install Nano Text Editor on Debian 11. For those of you who didn’t know, GNU nano is one of the popular and easiest command line text editors used on many operating systems including Unix-based systems and BSD variants. Nano text editor supports syntax highlighting, spell checking, justifying, completion, undo/redo, and many more.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘ sudo ‘ to the commands to get root privileges. I will show you through the step-by-step installation of the nano text editor on a Debian 11 (Bullseye).

Prerequisites

  • A server running one of the following operating systems: Debian 10 or Debian 11.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • A non-root sudo user or access to the root user . We recommend acting as a non-root sudo user , however, as you can harm your system if you’re not careful when acting as the root.

Install Nano Text Editor on Debian 11 Bullseye

Step 1. Before running the tutorial below, it’s important to make sure your system is up to date by running the following apt commands in the terminal:

Step 2. Installing Nano Text Editor on Debian 11.

By default, Nano is available on Debian 11 base repository, Now we nano to your Debian 11 system using the following command below:

So simply run the below command to check the version installed on your system:

Step 3. Use Nano Text Editor.

In this part, you are going to tips on how to open and close files. Also, a way to search and replace text. Then, we’ll exhibit you some editing hints and different user-friendly commands that you could use in Nano textual content editor:

The main syntax to open Nano and to edit a certain file is:

However, if you are in another folder and you want to open a file (file.txt) in the /path/to/directory , you can enter this line instead:

nano /path/to/directory/file.txt

To search in the text, press CTRL + W. Insert your value and press Enter. To continue searching for the same text string, use ALT + W.

Читайте также:  Как провести аудит linux

We have compiled the most useful commands to help you utilize the Nano text editor more effectively:

Command Explanation
CTRL + A Let’s jump to the beginning of the line.
CTRL + E Let’s you jump to the end of the line.
CTRL + Y Scrolls page down.
CTRL + V Scrolls page up.
CTRL + G A Help window will pop out and show you all the available commands.
CTRL + O To save the file. Nano will ask you to edit or verify the desired file name.
CTRL + W Search for a specified phrase in your text. Press ALT + W to search for the same phrase again.
CTRL + K It cuts the entire selected line to the cut buffer (similar to the clipboard).
CTRL + U To paste the text from the cut buffer into the selected line.
CTRL + J Justifies the current paragraph.
CTRL + C Shows the current cursor position in the text (line/column/character).
CTRL + R Opens a file and inserts it at the current cursor position.
CTRL + X To exit Nano text editor. It prompts a save request if you made any changes to the file.
CTRL + \ Replaces string or a regular expression.
CTRL + T Invokes the spell checker, if available.
CTRL + _ Let’s go to the specified line and column number.
ALT + A To select text. You can combine this command with CTRL + K to cut a specific part of the text to the cut buffer.

Congratulations! You have successfully installed nano. Thanks for using this tutorial for installing the latest version of the nano text editor on the Debian system. For additional help or useful information, we recommend you check the official nano website.

If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

Источник

Текстовый редактор Nano — как установить и использовать

img

При работе в командной строке довольно часто вам придется создавать или редактировать текстовые файлы. Два самых мощных и популярных редактора командной строки — это Vim и Emacs. У них обоих есть крутая кривая обучения, которая может быть пугающей для новых пользователей. Для тех, кому нужен простой редактор, есть nano.

Текстовый редактор Nano

GNU nano — это простой в использовании текстовый редактор командной строки для операционных систем Unix и Linux. Он включает в себя все основные функции, которые вы ожидаете от обычного текстового редактора, такие как подсветка синтаксиса, несколько буферов, поиск и замена с поддержкой регулярных выражений, проверка орфографии, кодировка UTF-8 и многое другое.

В этом руководстве объясняются основные принципы использования редактора nano, включая способы создания и открытия файла, редактирования файла, сохранения файла, поиска и замены текста, вырезания и вставки текста и многое другое.

Установка nano

Текстовый редактор Nano предустановлен на MacOS и большинстве дистрибутивов Linux. Чтобы проверить, установлен ли он в вашей системе, выполните следующие действия:

Вывод будет выглядеть примерно так:

GNU nano, version 2.9.3 (C) 1999-2011, 2013-2018 Free Software Foundation, Inc. (C) 2014-2018 the contributors to nano Email: nano@nano-editor.org Web: https://nano-editor.org/

Если в вашей системе не установлен nano, вы можете установить его с помощью менеджера пакетов вашего дистрибутива.

Читайте также:  Linux как свернуть окно

Установка Nano в Ubuntu и Debian:

Установка Nano в CentOS и Fedora:

Открытие и создание файлов

Чтобы открыть существующий файл или создать новый файл, введите nano, а затем имя файла:

Откроется новое окно редактора, и вы сможете начать редактирование файла.

Внешний вид Nano

Внизу окна находится список самых основных командных ярлыков, которые можно использовать с нано.

Все команды имеют префикс ^ или M . Символ каретки (^) обозначает клавишу Ctrl . Например, команды ^ J означают одновременное нажатие клавиш Ctrl и J. Буква М обозначает клавишу Alt .

Вы можете получить список всех команд, набрав Ctrl + g .

Чтобы открыть файл, вы должны иметь права на чтение файла.

Если вы хотите открыть файл с курсором на определенной строке и символом, используйте следующий синтаксис:

nano +номер_строки,номер_символа filename

Если вы не укажите номер символа то, курсор будет расположен на первом символе.

Редактирование файлов

В отличие от vi, nano является немодальным редактором, что означает, что вы можете начать печатать и редактировать текст сразу после открытия файла.

Чтобы переместить курсор на определенную строку и номер символа, используйте команду Ctrl + _ . Меню в нижней части экрана изменится. Введите число в поле «Enter line number, column number» и нажмите Enter.

Поиск и замена

Чтобы найти текст, нажмите Ctrl + w , введите поисковый запрос и нажмите Enter. Курсор переместится к первому совпадению. Чтобы перейти к следующему совпадению, нажмите Alt + w .

Если вы хотите найти и заменить, нажмите Ctrl + . Введите условие поиска и текст, который нужно заменить. Редактор перейдет к первому совпадению и спросит вас, нужно ли его заменить. После нажатия Y или N он перейдет к следующему совпадению. Нажатие А заменит все совпадения.

Копирование, вырезка и вставка

Чтобы выделить текст, переместите курсор в начало текста и нажмите Alt + a . Это установит отметку выбора. Переместите курсор в конец текста, который вы хотите выделить, с помощью клавиш со стрелками. Выбранный текст будет выделен. Если вы хотите отменить выбор, нажмите Ctrl + 6 .

Скопируйте выделенный текст в буфер обмена с помощью команды Alt + 6 . Ctrl + k обрежет выделенный текст.

Если вы хотите вырезать целые строки, просто переместите курсор на линию и нажмите Ctrl + k . Вы можете вырезать несколько строк, нажав Ctrl + K несколько раз.

Чтобы вставить текст, наведите курсор на то место, куда вы хотите поместить текст, и нажмите Ctrl + u .

Сохранение и выход

Чтобы сохранить внесенные изменения в файл, нажмите Ctrl + o . Если файл еще не существует, он будет создан после его сохранения.

Для выхода из нано нажмите Ctrl + x . Если есть несохраненные изменения, вас спросят, хотите ли вы сохранить изменения.

Чтобы сохранить файл, вы должны иметь права на запись в файл. Если вы создаете новый файл, вам необходимо иметь разрешение на запись в каталог, в котором он создан.

Кастомизация nano

Параметры, указанные в пользовательских файлах, имеют приоритет над глобальными параметрами. Полный список доступных опций для nanorc можно посмотреть тут

Nano поставляется с правилами подсветки синтаксиса для большинства популярных типов файлов. В большинстве систем Linux файлы синтаксиса хранятся в каталоге /usr/share/nano и по умолчанию включены в файл конфигурации /etc/nanorc .

Подсветка синтаксиса

Самый простой вариант включить подсветку для нового типа файлов — это скопировать файл, содержащий правила подсветки синтаксиса, в каталог /usr/share/nano .

Установите Nano в качестве текстового редактора по умолчанию

По умолчанию в большинстве систем Linux текстовым редактором по умолчанию для таких команд, как visudo и crontab, является vi. Чтобы использовать nano в качестве текстового редактора по умолчанию, вам нужно изменить переменные окружения VISUAL и EDITOR.

Читайте также:  How to resize root partition linux

Пользователи Bash могут экспортировать переменные в файл ~/.bashrc :

export VISUAL=nano export EDITOR="$VISUAL"

Базовое использование Nano

Ниже приведены основные шаги для начала работы с nano:

  • В командной строке введите nano, а затем имя файла.
  • Отредактируйте файл как требуется.
  • Используйте команду Ctrl-x для сохранения и выхода из текстового редактора.

Вывод

В этой статье мы показали, как использовать текстовый редактор Gnu nano. Это популярный текстовый редактор среди пользователей Linux и имеет небольшую кривую обучения. Для получения дополнительной информации о Gnu Nano посетите официальную страницу документации nano.

Источник

How To Install nano on Debian 11

In this tutorial we learn how to install nano on Debian 11.

What is nano

GNU nano is an easy-to-use text editor originally designed as a replacement for Pico, the ncurses-based editor from the non-free mailer package Pine (itself now available under the Apache License as Alpine). . However, GNU nano also implements many features missing in Pico, including:

  • undo/redo
  • line numbering
  • syntax coloring
  • soft-wrapping of overlong lines
  • selecting text by holding Shift
  • interactive search and replace (with regular expression support)
  • a go-to line (and column) command
  • support for multiple file buffers
  • auto-indentation
  • tab completion of filenames and search terms
  • toggling features while running
  • and full internationalization support

There are three ways to install nano on Debian 11. We can use apt-get , apt and aptitude . In the following sections we will describe each method. You can choose one of them.

Install nano Using apt-get

Update apt database with apt-get using the following command.

After updating apt database, We can install nano using apt-get by running the following command:

sudo apt-get -y install nano 

Install nano Using apt

Update apt database with apt using the following command.

After updating apt database, We can install nano using apt by running the following command:

Install nano Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Debian. Update apt database with aptitude using the following command.

After updating apt database, We can install nano using aptitude by running the following command:

sudo aptitude -y install nano 

How To Uninstall nano on Debian 11

To uninstall only the nano package we can use the following command:

Uninstall nano And Its Dependencies

To uninstall nano and its dependencies that are no longer needed by Debian 11, we can use the command below:

sudo apt-get -y autoremove nano 

Remove nano Configurations and Data

To remove nano configuration and data from Debian 11 we can use the following command:

Remove nano configuration, data, and all of its dependencies

We can use the following command to remove nano configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge nano 

References

Summary

In this tutorial we learn how to install nano on Debian 11 using different package management tools like apt, apt-get and aptitude.

Источник

Оцените статью
Adblock
detector