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:
nano hello.txtopens a new text file named hello.txt in the nano text editor.
"Hello, I am nano"is a text string entered in nano at the line indicated by the cursor.
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.
- Ctrl + O saves a file.
Ostands for output. Again, not case-sensitive.
- Ctrl + X exits the nano program.
Xstands 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.
Open artists/hiphop.txt with
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.
To verify your edits were saved.