Questions tagged [nano]

nano is a simple command line text editor which comes preinstalled in Ubuntu by default.

Filter by
Sorted by
Tagged with
444 votes
7 answers
831k views

How to show line numbering in nano when opening a file

Is there a way to tell nano to automatically show line numbering each time I open a file?
Luis Alvarado's user avatar
270 votes
4 answers
521k views

Any way to search for text within nano?

Nano is the editor I use in command prompts. When I open a large file I would like to search for some text (think Ctrl + F). Is there a way to do this?
JD Isaacks's user avatar
  • 5,297
246 votes
15 answers
425k views

How do I enable syntax highlighting in nano?

Can nano do syntax highlighting like gedit and vim? How can I enable it? I need at least bash and python syntax highlights.
Oxwivi's user avatar
  • 17.9k
211 votes
2 answers
229k views

How to change visudo editor from nano to vim? [duplicate]

When I use visudo, it always opens it with nano editor. How to change the editor to vim?
dedunu's user avatar
  • 9,186
204 votes
3 answers
311k views

How to use Undo functionality in Nano?

I use the commmand line text editor nano. How do I undo an action while editing text? For example: I typed some text and then changed my mind. Now I want to return to previous state. How?
user44's user avatar
  • 2,143
165 votes
13 answers
448k views

How do I delete multiple lines in nano without affecting the clipboard?

I can select all file by going to the 1st line Alt+\, start marking the text by Alt+A, go to the last line by Alt+/ But there, I don't know which key to remove the selected text. Hit delete doesn't ...
Nam G VU's user avatar
  • 2,278
147 votes
8 answers
500k views

Copy (only copy, not cutting) in Nano?

I need to copy some text in Nano, so I searched using Google and found a few posts here on Stack Exchange and other sites in which the OP asks "How can I copy?" and people usually answer "You can use ...
user avatar
136 votes
4 answers
809k views

How to save a file using nano

I am trying to install Java via the terminal using the guide How to Install Oracle Java JRE on Ubuntu Linux. Everything went perfectly fine until "Step 11: Save the /etc/profile file and exit": I ...
user288690's user avatar
  • 1,563
101 votes
2 answers
119k views

Delete whole line in nano editor

some times while I am editing my files with nano I am facing difficulty while deleting some big line, I need to hold Del key for long time. is there any shortcut I can found to delete the total line ...
Raja G's user avatar
  • 102k
84 votes
4 answers
151k views

How do I get back to nano after hitting Ctrl-Z if I have no shell prompt (in Matlab session)

I'm using nano inside a MATLAB session that is running inside a screen (-x) terminal. I accidentally hit Ctrl-Z and it immediately leaves nano, prints "Use "fg" to return to nano", but does not show ...
user282315's user avatar
67 votes
6 answers
186k views

How to switch the editor in mc (midnight commander) from nano to mcedit?

Using ubuntu 10.10 the editor in mc (midnight commander) is nano. How can i switch to the internal mc editor (mcedit)?
sdu's user avatar
  • 1,590
62 votes
5 answers
552k views

How to edit files in a terminal with nano?

Sometimes, a graphical text editor like gedit or kate cannot be used (because you're in a virtual console for example). Luckily, there are text editors for the terminal. An easy one is nano, but I ...
Lekensteyn's user avatar
  • 174k
59 votes
6 answers
142k views

Difference between Nano and Vim

I have recently started using Ubuntu and hence, the terminal. As text editor, I have used the pre-installed nano. Now I wonder whether I should install and use vim as well. What are each of those ...
Maxsash's user avatar
  • 773
42 votes
6 answers
114k views

Getting error while opening /etc/profile: Error reading lock file /etc/.profile.swp: Not enough data read

I am getting this error while opening /etc/profile file using nano. Error reading lock file /etc/.profile.swp: Not enough data read How can I fix this?
Vaibhav Phadke's user avatar
38 votes
2 answers
37k views

How do I get spaces instead of tabs in nano?

I usually edit Python files with nano, so I need four spaces instead of a tab. How can I get nano to automatically insert spaces for tabs, and control how many of them it inserts?
Stefano Palazzo's user avatar
37 votes
4 answers
22k views

Change the default editor when sudo visudo

When doing sudo visudo, the default editor is nano. I want to change it to vi or vim. I already made vim the default editor, and use it as a substitute for gedit to open php, .txt, .c and .h files,...
Cbhihe's user avatar
  • 2,761
29 votes
1 answer
28k views

"file /var/log/syslog is being edited" message in nano

To the best of my knowledge, I can view /var/log/syslog with the command sudo nano /var/log/syslog and successfully did so several times during a session; however, I was trying to search the log for ...
munr0's user avatar
  • 291
28 votes
1 answer
91k views

How to delete selected text in nano editor? [duplicate]

How do I delete selected text in the nano editor? I came across this issue while needing to delete the virtual host file and replace its content completely by other content. But the problem is that I ...
vaibhav's user avatar
  • 405
26 votes
2 answers
27k views

What are '.save' files?

I have been writing several bash scripts, and I have found that while writing them that extra copies of the files have been created which seem to be identical in contents to the normal files, except ...
user avatar
21 votes
3 answers
62k views

Save an edited file in nano, but no permissions

I edited a file in /etc/ that I want to save, but forgot to open it using sudo. I remember there was a command to save such a file in vi, and want to know if there is any such way to do it in nano? ...
theTuxRacer's user avatar
  • 16.2k
20 votes
2 answers
58k views

Edit crontab with an editor other than the default

I would like to edit crontab with vi once. My default editor is nano, and I want to keep it that way. I only want to edit with vi one time. I don't want to change the default to vi then back to ...
D. Clancy's user avatar
  • 201
18 votes
4 answers
19k views

How to move the blinking cursor with the mouse in nano editor?

I am writing a text file through the terminal using nano; everytime I need to select a position of a certain line of my text I can't help but scrolling all the lines moving the blinking cursor using ...
Federico Gentile's user avatar
18 votes
4 answers
5k views

Bind Ctrl+Right to nextword in nano (as it is in all other apps)

And likewise Ctrl+Left to prevword. I read the man page of nanorc and found bind key function menu So the line bind ^Left prevword main would be what I want, the problem is that nano only accepts ...
turbo's user avatar
  • 4,622
17 votes
6 answers
196k views

'[Error writing /filename: Permission denied]' while trying to save a file using the nano editor

Using the Nano text editor, I'm trying to save and exit a file. I already have the file named. I click Ctrl+X to exit. And then I click Y because I want to save the file. It asks for file to write, ...
Renee's user avatar
  • 179
17 votes
2 answers
18k views

.nano_history permissions error

I use rkhunter and I was wanting to check its logs with: nano /var/log/rkhunter.log But nano outputted this error: Error reading /home/arthur-dent/.nano_history: Permission denied Press Enter to ...
user avatar
17 votes
2 answers
12k views

How to exit nano and save to current file automatically?

Whenever I close nano after having edited an existing file, it first asks if I'd like to save the file (which is fine), and then asks me to confirm the filename (so I press Enter, since literally 100% ...
laurent's user avatar
  • 284
15 votes
2 answers
15k views

How can I change the keyboard shortcuts in nano?

To indent a whole block of code in nano, after selecting it with alt+a, I have to press alt+{, which doesn't work on my german layout macintosh keyboard (and would be pretty annoying even if it did). ...
Stefano Palazzo's user avatar
14 votes
2 answers
147k views

Create , Write and Save file from a Shell script

I don't want to write the file manually, so I made a shell-script. Is there a way to write & save the file automatically without getting the user to press keys? sudo nano blah #write stuff to ...
ntakouris's user avatar
  • 265
11 votes
2 answers
47k views

No such file or directory when trying to create a file with nano

I am trying to create a new file: nano/etc/apt/apt.conf.d/02proxy When upgrading from 14.04 to 16.04, but I'm getting the error: No such file or directory
Anesu Gerry Mangwiro Black Whi's user avatar
10 votes
2 answers
49k views

nano M-A hotkey

When using nano in the terminal, to do the "write file append" command, it lists the keystroke "M-A". I am completely confused what this key command actually means. I read somewhere that it means Alt-...
Scorb's user avatar
  • 780
8 votes
2 answers
17k views

Setting permanent export EDITOR to nano for all future sessions [duplicate]

Every time I SSH into my AWS, I am changing editor to nano. Is there a command to run that will change it to nano for all future instances a well?
Vantage's user avatar
  • 81
8 votes
1 answer
7k views

Can I enable bracket matching in nano?

else if( d && ( (d <= b && d <= s) || (!b && !s) ) smallest = d Consider this piece of code of C++. Can we have bracket matching (highlighting opening bracket when ...
owsmmj's user avatar
  • 301
7 votes
2 answers
7k views

Getting nano nanorc settings to work with "sudo nano" command

Anyone know how to get nanorc settings (syntax highlighting, mouse) to work when using the "sudo nano" instance of the editor? It works as expected when not using nano as a super-user but not with ...
nilblank's user avatar
7 votes
2 answers
3k views

How do I set the global nano background to black

I am using GNU nano version 4.8 on Ubuntu 20.04 LTS. I have X11 set up to use white as the background colour of the xterm window. I don't want to change this setting. It looks like nano inherits this,...
Free Radical's user avatar
6 votes
2 answers
7k views

Getting error with spell check in nano

I am getting the following error while doing spell check in nano editor. Please help to resolve this. Spell checking failed: Error invoking "spell": Bad file descriptot
samarasa's user avatar
  • 4,731
6 votes
3 answers
10k views

How do I remove hidden backup files?

I have files ending in ~ in my home directory, and I want to delete them. How do I do that? How do I prevent this backup functionality?
Flair's user avatar
  • 517
6 votes
3 answers
18k views

How to set nano default syntax highlighting for files with no extension?

I'm trying to set a 'default' syntax highlighting scheme for nano when I'm editing files with no extension such as /etc/nginx/sites-available/default or /etc/ssh/sshd_config but I can't seem to make ...
AJB's user avatar
  • 187
6 votes
3 answers
17k views

Where is the nano file located? [duplicate]

I'm using FileZilla and have found the default LibreOffice Writer not the best for on-the-go code editing. I have the option to use custom program for text editing, so why not give nano a go. So I'm ...
Jack Hales's user avatar
6 votes
4 answers
20k views

How can one copy text from nano in Ubuntu WSL2 and paste it into a Windows application?

Microsoft has made this nifty tool called Windows Subsystem for Linux. WSL2 creates a lightweight VM running Linux (in this case Ubuntu) to facilitate using Linux on Windows. Within WSL2 (Ubuntu) I'...
davemackey's user avatar
6 votes
2 answers
4k views

How can I enable syntax highlighting in a Python file without an extension?

Turning on syntax highlighting in Nano is simple enough but I've just run into a non-standard issue. I have an executable Python script that doesn't have an extension. It's part of a virtualenv ...
Oli's user avatar
  • 294k
6 votes
1 answer
1k views

Extend nano menu

Some hotkeys for nano are listed in the bottom depends on window scaling. How can I switch through this menu to see all the available hotkeys?
Hölderlin's user avatar
5 votes
3 answers
9k views

Delete word before and after the cursor in nano editor

How can I delete the word before and the word after the current position of the cursor in nano editor? (For the sake of clarity: I mean two distinct editions under this description, like the Ctrl-...
Hendrik's user avatar
  • 225
5 votes
1 answer
3k views

Opening this file in nano shows peculiar red area

I have a simple text file. When I open it with nano, there is a red area covering space in front of some of the text. I have never seen this: What can I do about this?
Cyrill's user avatar
  • 61
5 votes
1 answer
6k views

How to enable undo in nano?

How can I enable Undo in nano? I am using a ssh connection with a server. I can not update the version of nano that is installed on the server. Is there anyway to use GNU nano 2.3.1 to have Undo ...
saeed mohammadi's user avatar
5 votes
2 answers
3k views

How to insert timestamp in nano editor?

I need a time-stamp that is inserted with a hot key, like F5 in old notepad. Format should be: hh:mm dd.mm.yyyy. p.s. Dot in the end of the year is grammatically correct in Serbian language, so it ...
Igor V.'s user avatar
  • 948
4 votes
2 answers
57k views

How to display line numbers in Nano text editor [duplicate]

When using Nano text editor, how can I display line numbers so I can see the lines that I am getting error messages about. I have a lengthy program and am getting an error message for line 95 and 125 ...
Robert W.'s user avatar
4 votes
1 answer
4k views

date command not resolving properly in bash alias

I'm trying to set up a way for me to just type newjournal, and a new journal entry named year-month-date-time.txt is created in a year subdirectory in ~/documents/journals. I've got it set up as an ...
YMGenesis's user avatar
  • 103
4 votes
2 answers
3k views

Editing with nano, Alt is caught by the window menus, how can I fix that?

The Alt key is used for many useful commands, but unfortunately it's caught by the terminal window to activate the window menus (File, Edit, ...). I would like to either force the terminal window to ...
drevicko's user avatar
  • 4,373
4 votes
2 answers
1k views

WSL Nano scrolling up to see terminal

I run some commands on remote server (am connected with it via ssh using WSL ubuntu 20) and after running then I open nano editor, usually I was able to scroll up with my mouse witch allowed me to see ...
asdasd123's user avatar
4 votes
1 answer
251 views

Why can't I see the character _ while using Nano on Yakuake?

I use Gnu Nano on Yakuake to write a LaTeX-document. Then yesterday I found that I can't see the character _ on the Nano. I know that the characters are there as LaTeX renders the tex-file correctly. ...
Jaakko Seppälä's user avatar