Skip to content

Practice Exercise: Using Basic Text Editors - nano and gedit

Objective

Learn how to use basic text editors, specifically nano in a Linux environment.

Task 1: Editing a Text File with nano

  • Open a terminal window.
  • Create a new text file named nano_notes.txt using the nano text editor.
  • Write a short note or description in the file.
  • Save and exit the nano editor.
  • Verify that the file my_notes.txt was created and contains your note.
[intern@intern-a1t-inf-lnx1 ~]$ nano nano_notes.txt
 UW PICO 5.09                               File: nano_notes.txt

This is a nano test
^G Get Help     ^O WriteOut     ^R Read File    ^Y Prev Pg      ^K Cut Text     ^C Cur Pos
^X Exit         ^J Justify      ^W Where is     ^V Next Pg      ^U UnCut Text   ^T To Spell
# Press ^X 
Save modified buffer (ANSWERING "No" WILL DESTROY CHANGES) ?
                Y Yes
^C Cancel       N No
# Press Y
File Name to write : nano_notes.txt
^G Get Help     ^T  To Files
^C Cancel       TAB Complete
# Press enter
[intern@intern-a1t-inf-lnx1 ~]$ cat nano_notes.txt
This is a nano test

Task 2: Editing an Existing File with nano

  • Use nano to open the nano_notes.txt file you created earlier in Task 1.
  • Add some additional notes or make changes to the existing content.
  • Save your changes and exit nano.
    [intern@intern-a1t-inf-lnx1 ~]$ nano nano_notes.txt
      UW PICO 5.09                           File: nano_notes.txt                           Modified
    
    This is a nano test to edit file.
    # Press ^X 
    Save modified buffer (ANSWERING "No" WILL DESTROY CHANGES) ?
                    Y Yes
    ^C Cancel       N No
    # Press Y
    File Name to write : nano_notes.txt
    ^G Get Help     ^T  To Files
    ^C Cancel       TAB Complete
    # Press enter
    

Conclusion

In this lab exercise, you've practiced using two basic text editors, nano commonly available in Linux environments. You've learned how to create, edit, and save text files using both terminal-based and graphical editors. Understanding these text editors is essential for various Linux-related tasks and system administration.