Learn
Environment
Nano

Nice job! You just edited a file in the nano text editor. How does it work?

$ nano hello.txt

nano is a command line text editor. It works the same way as a desktop text editor like TextEdit or Notepad, except that it is accessible from the command line and only accepts keyboard input.

Let’s walk through what we did in the previous exercise:

  1. The command nano hello.txt opens a new text file named hello.txt in the nano text editor.

  2. "Hello, I am nano" is a text string entered in nano at the line indicated by the cursor.

  3. The menu of keyboard commands at the bottom of the window allow us to save changes to hello.txt and exit nano. The ^ stands for the Ctrl key.

This image shows the help menu at the bottom of Nano, shows us what the Ctrl key + each letter does. Ctrl + G means Get help, Ctrl + O means Write Out, Ctrl + R means Read File, Ctrl + Y is Previous Page, Ctrl + K is Cut Text, Ctrl + C is changing cursor position, Ctrl + X is exit, Ctrl + J is justify, Ctrl + W is Where Is, Ctrl + V is Next Page, Ctrl + U is UnCut Text, and Ctrl + T is To Spell.
  • Ctrl + O saves a file. O stands for output. Again, not case-sensitive.
  • Ctrl + X exits the nano program. X stands for exit.
  • Ctrl + G opens a help menu.

Outside of nano, you can also use clear to clear the text in the current terminal window, moving the command prompt to the top of the screen. This is useful for when you want to make the terminal more readable after many commands.

In this lesson, we’ll use nano to implement changes to the environment. You can learn more about nano here.

Instructions

1.

Open artists/hiphop.txt with nano.

2.

In this opened file, add “Kendrick Lamar” to the first line.

Type Ctrl + O to save the file.

Press Enter to write the filename.

Type Ctrl + X to exit.

Finally, type

cat artists/hiphop.txt

To verify your edits were saved.

Folder Icon

Sign up to start coding

Already have an account?