Editing Existing Files in the Command Line

Let's say we need to edit this file. The command to do that is actually the same one that we used to create it.

In the command line, type "vi Test.txt" and press Enter.

Now we see the file that we just created. I can make my changes by pressing "i" to enter "Insert" mode, I'll move to the end of the row and press Return to create a new line, and finally type "Here's the second line.". Now, we can save the file and close it.

Previously, we saved the file with the ":w" command and then quit the file with the ":q" command. Since these are commonly used together, you can actually combine them into one command. I'll hit escape, and then type ":wq" and press Enter.

That saves the file, quits it and takes us back to the file structure. If you'd like to check, you can simply type "vi Test.txt" and you'll see the new line.