Перейти к содержимому

Как установить nano на ubuntu

  • автор:

Ubuntu Documentation

GNU nano is a simple terminal-based text editor. Though not as powerful as Emacs or Vim, it is easy to learn and use. Nano is ideal for making small changes to existing configuration files or for writing short plain text files. It was originally created as a free replacement for the non-free Pico editor. Pico is the terminal-based editor used in the Pine email suite from the University of Washington.

Nano can be used in a terminal window or at the system console.

Basic use of nano is covered here. If you want to learn more advanced techniques such as the use of multiple buffers or syntax highlighting of code, see the the nano project’s documentation.

Installing Nano

Nano is part of the standard Ubuntu installation, and should be on your system already. If for some reason it’s not, use your favorite package manager to install nano.

Using Nano

Nano is a terminal-based command-line program. Although not complicated or difficult to use, it is different than a GUI-based text editor such as gedit. The two main features that differ are the short-cut key combinations and the use of a mouse.

Starting Nano

To start nano with an empty file, open a terminal window and at the command-line type «nano» (without the quotes). For example:

To open an existing file for editing, type «nano filename» where filename is the name of the existing file. For example, to open the file that contains the list of most recently issued commands, make sure you are in your home directory, and at the command line type «nano .bash_history» as in the following example:

In the above example, if the file .bash_history does not exist in your current directory, nano will start a new blank file and use .bash_history as the name for it.

Line wrap is on by default. When line wrap is on, nano inserts end-of-line characters into your file when it wraps lines to fit the width of the terminal window. Only lines that you type or paste into the window are wrapped. Existing long lines are not wrapped until you add new text to the line or use the Ctrl+J key combination to justify the current paragraph.

Screen Layout

Figure 1: Default nano screen layout

The default nano screen layout is as shown in Figure 1. The bottom two lines show the key combinations for common operations. The ^ symbol represents the Control key on your keyboard. For example, use the Ctrl+G key combination to display a basic introduction to nano and its default screen layout.

The screen fonts and background colours are determined by your terminal settings. And when you resize the terminal window, nano adjusts itself accordingly.

Long lines that are not wrapped to fit the window are indicated by the $ symbol at the extreme right edge of the terminal window. The $ symbol is not part of your file; it just tells you that the line of text is too long to be displayed in the terminal.

Using The Mouse

By default, mouse services are provided by the terminal window. The mouse works almost the same as in a GUI editor. You can highlight text, right-click to copy and paste, and use the middle mouse button for pasting text from the buffer. However, when you use the middle mouse button to paste text, the text is pasted at the current cursor location, not at the mouse pointer location. Other limitations exist. For example, you cannot use the mouse to cut or delete text, nor can you use the mouse to scroll through the file.

Nano has its own built-in mouse services, but they are limited. They provide only the ability to move the cursor to the point where you click, and to mark the beginning and end of a section of text. Use the Alt+M key combination to toggle between using the terminal’s mouse services and nano’s built-in mouse services.

Using the Keyboard

Typing at the keyboard will insert text at the current cursor location. The Page Up and Page Down keys, the Arrow keys, and the Insert key and Delete key all work as in most other text editors. If you are at a keyboard that does not have these keys, you can use alternative Ctrl+key combinations. They are listed in nano’s online help, accessible with the Ctrl+G key combination.

Copy, paste, and cut operations are available, but they do not use the same Ctrl+key sequences as in most GUI editors. See the Editing Text section for more information.

Opening, Saving, and Closing Files

You can open a file for editing when you start nano, as discussed in the Starting Nano section. This section shows you how to open a file when nano is already started.

Opening Files

Open a file with the Read File command, Ctrl+R. The Read File command inserts a file from disk at the current cursor location.

When prompted, type the name of the file you want to open, or use the Ctrl+T key combination to use nano’s built-in file browser to navigate to the file you want to open.

If a file is already open, nano will insert the new file into it at the current cursor location; it will not close the existing file, nor will it open a new screen for the new file.

Save and Save As

Save and Save As are both accomplished with the Write Out command, Ctrl+O.

When prompted, press enter to accept the existing file name. To save as another file name, type in the new name and press Enter, or use the Ctrl+T key combination to use nano’s built-in file browser.

Closing Files

Close a file with the Ctrl+X key combination. If the file you are working on has been modified since the last time you saved it, you will be prompted to save the file first. Type y to save the file, or n to exit nano without saving the file.

Closing a file also closes nano.

Editing Text

As is normal in most text editors, text that you type into nano is inserted at the current cursor position. The Delete and Backspace keys also work the same as in other editors.

Use the Alt+6 key combination to copy text to the «cut buffer». Similarly, use the Ctrl+K key combination to delete text (it is cut to the «cut buffer»). If no text is marked, these two commands copy or cut the entire line of text.

Use the Ctrl+U key combination to paste the text in the «cut buffer» into the file.

To cut or copy specific text, you must first mark the start and end points of the text you want to select. You can do this with the either keyboard or the mouse, but to use the mouse for marking you must first turn on nano’s built-in mouse services.

To use the keyboard to select text, move the cursor to the start of the text you want to select, press the Alt+A key combination to mark the start, then move the cursor to the end of the section you want to select.

To use the mouse to mark the start of a selection, first make sure that nano’s built-in mouse services are turned on. Use the Alt+M key combination to toggle between nano’s mouse and the terminal’s mouse. Click on the location where you want to mark the start of the selection, move to the end of the section you want to select, and click the mouse again. You might need to use the keyboard to scroll the screen up or down because nano does not support scrolling with the mouse.

Once you have marked the beginning and end of text, the Alt+6 and Ctrl+K key combinations can be used to copy or cut it, respectively.

If you are using nano in a terminal window you can use the mouse to copy and paste text to and from other windows on your desktop. You cannot use the mouse to cut or delete text.

Quitting Nano

To quit nano, use the Ctrl+X key combination. If the file you are working on has been modified since the last time you saved it, you will be prompted to save the file first. Type y to save the file, or n to exit nano without saving the file.

How to Install and Use Nano Text Editor: A Beginner’s Tutorial

How to Install and Use Nano Text Editor: A Beginner’s Tutorial

In this tutorial, you will learn how to use and install Nano, a popular text editor of Unix and Linux operating systems. Nano comes with many powerful features and allows you to edit and create various files on your computer or server. So let’s get right to it.

How to Install Nano Text Editor

This process depends on the operating system you are using. Some, like macOS or Linux distros, may already come with the Nano text editor pre-installed.

To check, simply use the following command:

If you see an output that tells you a version number, you can skip this section.

Installing Nano on Debian/Ubuntu

To install Nano text editor on Debian or Ubuntu machines, execute the following command:

Then, wait for the installation process to finish.

Important! The sudo part is meant for running this command as a root user. This means you may be prompted to enter a password in case you are currently not logged in as a root user.

Installing Nano on CentOS/RHEL

We can run this command to install Nano text editor on CentOS or RHEL based platforms:

That is it to install Nano. As soon as the setup ends, you can use it immediately.

How to Use Nano Text Editor

In this part, you are going to learn how to open and close files. Also, how to search and replace text. Then, we’ll show you some editing tips and other basic commands that you can use in Nano text editor.

How to Open and Close the Nano Editor

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

Let’s say we want to open a file named demo.txt. The command would look like:

You can open various file types, like .txt, .php, .html, and so on. Just keep in mind that if you want to open a specific file, you will need to be in the directory where the file is located.

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

If you enter a file name and that file is not present in the directory, Nano will create a new file. Meanwhile, if you only execute the nano command without specifying the file name, the Nano text editor will create an empty untitled file and ask for a name when you exit the editor.

After running the nano command, a new window will pop up where you can freely edit the file. Below is what the interface of the Nano text editor looks like. Just use the arrow keys on your keyboard to move the cursor around the text.

The interface of Nano text editor

At the bottom of the window, you can find some shortcuts to use with the Nano editor. The “^” (caret) means that you must press CTRL (Windows) or control (macOS) to use the chosen command. Here are a few examples.

  • Press CTRL + O to save the changes made in the file and continue editing.
  • To exit from the editor, press CTRL + X. If there are changes, it will ask you whether to save them or not. Input Y for Yes, or N for No, then press Enter. But if there are no changes, you will exit the editor right away.

Take note that whenever you are opening an important configuration file, it is recommended to use the -w option. It will open the file in a standard format. If you don’t use this option, nano will wrap the text to fit the display by default. The command will be like this:

How to Search and Replace Text

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.

If your goal is to find and replace a text, press CTRL+W and then CTRL+R to enter the text that you want to search and the text that will replace it. The editor will then take you to the first instance of the text. You can press Y to replace one text or A to replace all instances.

Should you want to go back after typing a shortcut, just use CTRL + C to cancel the current process.

How to Edit Text

These are the commonly used shortcuts when editing a text in Nano.

  • To select text, go to the beginning of the desired text and press ALT + A. This will set a mark for selecting. Then, you can move over the text with arrow keys.
  • Press ALT + 6 to copy the selected text to the clipboard.
  • To cut the highlighted text, press CTRL + K.
  • If you want to paste the text, navigate to the intended place and press CTRL + U.

Basic Nano Text Editor Commands

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

Conclusion

Nano is a popular and versatile terminal-based text editor in Linux. It is a perfect fit for beginners and professionals who are looking for a complete tool to modify their text.

In this tutorial, you have learned how to use the Nano text editor. We have shown you a lot of useful commands and editing tips to improve your workflow. Now, we hope that you can easily edit text without having to download and re-upload the file.

Good luck, and be sure to check our other SSH and VPS tutorials.

Domantas leads the content and SEO teams forward with fresh ideas and out of the box approaches. Armed with extensive SEO and marketing knowledge, he aims to spread the word of Hostinger to every corner of the world. During his free time, Domantas likes to hone his web development skills and travel to exotic places.

Как установить nano в Ubuntu / Debian

Для установки nano в Ubuntu / Linux Mint / Debian, введите в Терминал :

nano — маленький, удобный текстовый редактор, вдохновленный Пико

Подробная информация о пакете:

Маленький, удобный текстовый редактор, вдохновленный Пико

Зависимости:

Библиотека GNU C: общие библиотеки

Разделяемые библиотеки для обработки терминала (широкая поддержка символов)

Как установить Nano на Ubuntu 20.04 LTS

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

В этой статье предполагается, что у вас есть хотя бы базовые знания Linux, вы знаете, как использовать оболочку, и, что наиболее важно, вы размещаете свой сайт на собственном VPS. Установка довольно проста и предполагает, что вы работаете с учетной записью root, в противном случае вам может потребоваться добавить ‘ sudo ‘ к командам для получения привилегий root. Я покажу вам пошаговую установку текстового редактора Nano в Ubuntu 20.04 (Focal Fossa). Вы можете следовать тем же инструкциям для Ubuntu 18.04, 16.04 и любого другого дистрибутива на основе Debian, например Linux Mint.

Установите Nano на Ubuntu 20.04 LTS Focal Fossa

Шаг 1. Во-первых, убедитесь, что все ваши системные пакеты обновлены, выполнив следующие apt команды в терминале.

Шаг 2. Установка Nano на Ubuntu 20.04.

Просто веселое видео для отвлечения и расслабления в течение 2 минут

Чтобы установить текстовый редактор Nano в системе Ubuntu, выполните следующую команду:

Вы можете проверить, установлен ли nano или нет, выполните следующую команду:

Шаг 3. Как использовать нано-текстовый редактор.

В этой части вы дадите советы, как открывать и закрывать файлы. А также способ поиска и замены текста. Затем мы покажем вам несколько советов по редактированию и различные удобные команды, которые вы можете использовать в редакторе текстового контента Nano:

Основной синтаксис для открытия Nano и редактирования определенного файла:

Для поиска в тексте нажмите CTRL + W . Вставьте свое значение и нажмите Enter . Чтобы продолжить поиск того же текста строки, используйте ALT + W .

Мы собрали самые полезные команды, которые помогут вам более эффективно использовать текстовый редактор Nano:

Command Объяснение
CTRL + A Позволяет перейти к началу строки.
CTRL + E Позволяет перейти к концу строки.
CTRL + Y Прокручивает страницу вниз.
CTRL + V Прокручивает страницу вверх.
CTRL + G Помощь окно выскочит и покажет вам все доступные команды.
CTRL + O Чтобы сохранить файл. Nano попросит вас отредактировать или подтвердить желаемое имя файла.
CTRL + W Найдите в тексте указанную фразу. Нажмите ALT + W, чтобы снова найти ту же фразу.
CTRL + K Он вырезает всю выбранную строку до буфера вырезки (аналогично буферу обмена).
CTRL + U Вставить текст из вырезанного буфера в выделенную строку.
CTRL + J Выравнивает текущий абзац.
CTRL + C Показывает текущую позицию курсора в тексте (строка / столбец / символ).
CTRL + R Открывает файл и вставляет его в текущую позицию курсора.
CTRL + X Для выхода из текстового редактора Nano. Он запрашивает сохранение, если вы внесли какие-либо изменения в файл.
CTRL + \ Заменяет строку или регулярное выражение.
CTRL + T Вызывает программу проверки орфографии, если она доступна.
CTRL + _ Позволяет перейти к указанной строке и номеру столбца.
ALT + A Выделить текст. Вы можете комбинировать эту команду с CTRL + K, чтобы вырезать определенную часть текста в буфер вырезания.

Поздравляю! Вы успешно установили Nano . Благодарим за использование этого руководства по установке текстового редактора Nano в системе Ubuntu 20.04 LTS Focal Fossa. Для получения дополнительной помощи или полезной информации мы рекомендуем вам посетить официальный сайт GNU Nano .

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *

Luxury Car Rental in Miami | Reserve a Premium Vehicle with RealCar