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

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.

主站蜘蛛池模板: 收藏| 榆林市| 卓资县| 二连浩特市| 大邑县| 富平县| 陇西县| 西吉县| 抚远县| 萝北县| 石城县| 广昌县| 绥滨县| 柳江县| 江达县| 南召县| 鱼台县| 宁南县| 得荣县| 乐陵市| 陵川县| 桂林市| 石景山区| 镇安县| 柘荣县| 威信县| 会昌县| 安岳县| 噶尔县| 乌审旗| 巩义市| 类乌齐县| 辽源市| 邵阳市| 元江| 安达市| 仙桃市| 马山县| 平定县| 绥棱县| 甘南县|