官术网_书友最值得收藏!

The nano editor

The nano editor is a very popular and easy-to-use command-line editor. You can open the nano editor by running the nano command:

elliot@ubuntu-linux:~$ nano

This will open up your nano editor, and you should see a screen like that in the following screenshot:

Figure 4: Inside nano

Now add the six lines that are shown in the following screenshot:

Figure 5: Add these six lines

Look at the bottom of the nano editor screen; you will see a lot of shortcuts:

Figure 6: nano shortcuts

I have included all the useful nano shortcuts in the following table:

Table 5: nano shortcuts

Notice that the Ctrl+O shortcut is triggered by pressing Ctrl and then the letter O. You don't have to press the + key or the upper case letter O.

Now let's use the shortcut Ctrl+O to save the file; it will ask you for a filename, you can insert facts.txt:

Figure 7: Saving the file

Then press Enter to confirm. Now let's exit the nano editor (use the Ctrl+shortcut) to verify that the file facts.txt is created:

elliot@ubuntu-linux:~$ ls -l facts.txt
-rw-r--r-- 1 elliot elliot 98 Apr 30 15:17 facts.txt

Now let's open facts.txt again to fix the false facts we have added there! To open the file facts.txt with the nano editor, you can run the nano facts.txt command:

elliot@ubuntu-linux:~$ nano facts.txt

The first line in the file facts.txt states that "Apples are blue." We certainly need to correct this false fact, so let's use the shortcut Ctrl+\ to replace the word blue with red.

When you press Ctrl+\, it will ask you to enter the word that you want to replace; you can enter blue, as shown in the following screenshot:

Figure 8: The word to replace

Hit Enter, and then it will ask you to enter the substitute word. You can enter red, as shown in the following screenshot:

Figure 9: The substitute word

You can then hit Enter, and it will go through each instance of the word blue and ask you if you want to replace it. Luckily, we only have one occurrence of blue.

Figure 10: Replacing blue with red

Press Y and BOOM! The word red replaced blue.

Figure 11: red replaced blue

There is one more word we need to change here. We can all agree that the Earth is not flat, right? I hope we all do! Now let's replace the word flat with round precisely as we did before, and the result should be like the one shown in the following screenshot:

Figure 12: flat replaced with round

Now let's save and exit the file. So we use the Ctrl+O shortcut to save and then Ctrl+X to exit.

The nano editor is pretty simple to use. And practice makes perfect, so the more you use it, the easier it will become for you. You can practice all the shortcuts in Table 5 as an exercise.

主站蜘蛛池模板: 章丘市| 铜梁县| 石棉县| 迁安市| 临西县| 磐安县| 灵宝市| 安仁县| 淮阳县| 秦皇岛市| 屏东县| 噶尔县| 淮阳县| 凉山| 广德县| 伊吾县| 长白| 大洼县| 连平县| 宾阳县| 玉龙| 芜湖市| 桐柏县| 东乡| 仪陇县| 青冈县| 驻马店市| 双城市| 夏津县| 开鲁县| 旺苍县| 县级市| 临武县| 比如县| 葫芦岛市| 永平县| 财经| 调兵山市| 蛟河市| 白玉县| 芦山县|