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

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.

主站蜘蛛池模板: 莱西市| 寿阳县| 会理县| 雷州市| 金昌市| 永嘉县| 邯郸市| 玉龙| 兰州市| 广灵县| 宜昌市| 岑巩县| 万载县| 龙南县| 集安市| 余姚市| 普洱| 麻江县| 渝中区| 淮阳县| 海安县| 山东省| 阳西县| 吐鲁番市| 浦城县| 云霄县| 平和县| 大化| 原平市| 阿克| 平武县| 巴中市| 砀山县| 长汀县| 巩留县| 航空| 通州市| 堆龙德庆县| 荔波县| 临清市| 井陉县|