Shell and DoC Systems, Lab 1
The Linux Terminal and Scientia
Chapter 4: Editing and viewing files
Editing files
Make sure you’re in ~/modules/shell/misc
, and make an empty
file, mynotes.txt
:
username@MACHINE:misc$ touch mynotes.txt
To edit this file from within the terminal, we can use the program
nano
. This is a simple text editor designed to work using keyboard
commands only—without the use of a mouse.
Although nano
won’t be the main editor you use for writing code, it’s
useful for quick edits to files—and very useful if you’re logged in
to a machine without a graphical user interface. (For instance—typically,
if you’re logged in remotely, from home.)
Let’s edit mynotes.txt
.
username@MACHINE:misc$ nano mynotes.txt
You’ll see something like the following:
You can proceed to edit the file, just as you would using any other editor.
- To move the cursor around, use the cursor keys instead of the mouse.
- To save the file, use Ctrl+O
- To exit the editor, use Ctrl+X
Exercise 11
- Write some text in the file
mynotes.txt
, and save it. - Exit
nano
, and view details of the file usingls -l
. (Notice that the size of the file now corresponds to the amount of text you’ve saved in it.)