In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
GNU nano is a commonly used text editor under Unix system, which is famous for its simplicity and ease of use. In contrast, with the more powerful Vi and Emacs editors, the learning curve is much steeper than nano. Since nano is enough for general text editors, I'd like to introduce it briefly to get started.
Basic use
You can start nano by entering the following command in Shell:
Nano test.txt
The command nano is followed by the name of the file you want to change. If a file named test.txt exists in the current folder, the change command will open the file. Otherwise, nano creates a new file. Shell then enters the editing interface of nano. Nano is edited in a WYSIWYG manner similar to the usual notepad tools. With the next key, you can move the cursor to the location you want to edit, and then enter or delete it.
When you are finished, you can press Ctrl+O to save the file. Nano asks if you want to save changes in the cache:
Save modified buffer (ANSWERING "No" WILL DESTROY CHANGES)?
Enter Y and the changes will be saved to the file. At this point, nano will ask you to reconfirm the file name of the saved file:
File Name to Write: test.txt
After the enter confirmation, the revision will be saved in the test.txt file.
Then, press Ctrl+X to exit nano and return to the command line of Shell.
Function key
There are many function keys in nano. For example, the Ctrl+O used to keep files above is a function key. A prompt for the function key is given at the bottom of the nano interface:
In the prompt, ^ represents the Ctrl key and M represents the Alt key. Therefore, ^ G represents both the Ctrl key and the G key.
Here are some common function keys:
M -\ move the cursor to the beginning of the text / move the cursor to the end of the text Mmura starts selecting the line where the text block ^ K is cut or the selected text block Mmur6 copies the line or the selected text block ^ U paste
^ G help
Syntax highlighting
Nano can support syntax highlighting to better serve programming. To use syntax highlighting, first install the syntax highlight file:
Git clone https://github.com/nanorc/nanorc.gitcd nanorc/make install
After the installation is complete, you can see that there are a lot of syntax highlighted files under ~ / .nano / syntax:
ALL.nanorc go.nanorc markdown.nanorc ruby.nanorcawk.nanorc html.nanorc mpdconf.nanorc sed.nanorcc.nanorc ini.nanorc nanorc.nanorc shell.nanorccmake.nanorc inputrc.nanorc nginx.nanorc sql.nanorccoffeescript.nanorc java.nanorc patch.nanorc systemd.nanorccolortest.nanorc javascript.nanorc peg.nanorc tex. Nanorccsharp.nanorc json.nanorc php.nanorc vala.nanorccss.nanorc keymap.nanorc pkg-config.nanorc vi.nanorccython.nanorc kickstart.nanorc pkgbuild.nanorc xml.nanorcdefault.nanorc ledger.nanorc po.nanorc xresources.nanorcdot.nanorc lisp.nanorc privoxy.nanorc yaml.nanorcemail.nanorc lua.nanorc properties.nanorc yum .nanorcgit.nanorc makefile.nanorc python.nanorcglsl.nanorc man.nanorc rpmspec.nanorc
Adding syntax highlighting files to ~ / .nanorc enables nano to initiate syntax highlighting support for the appropriate language, for example:
Include ~ / .nano/syntax/c.nanorcinclude ~ / .nano/syntax/css.nanorcinclude ~ / .nano/syntax/java.nanorcinclude ~ / .nano/syntax/makefile.nanorcinclude ~ / .nano/syntax/php.nanorcinclude ~ / .nano/syntax/python.nanorcinclude ~ / .nano/syntax/ruby.nanorcinclude ~ / .nano/syntax/tex.nanorcinclude ~ / .nano/syntax/xml.nanorc
If necessary, you can add more syntax highlighting files to .nanorc. When you open the supported program text again, you can see the syntax highlighting effect. In the following figure, a Python program is opened with nano:
In nano, the syntax highlighting function can be turned on and off by using the Mmury function key.
File basic operation
After editing the file with nano and saving it, a new file appears in the current directory, and the file name is the file name we used when we used it. You can display files in the current directory of Shell with the following command:
$ls
Linux stores data as files. In raspberry pie, the files are stored on that SD card. In addition to the user editing the generated text, the data may also be a program or configuration file in the Linux system. Under Unix's philosophy, a file is the only form of data storage, and even the hardware is virtualized into a file. Since files play such an important role, there are naturally commands in Linux for manipulating files, such as rm for deleting files:
$rm test.txt
The location where the file is stored is called the directory where the file is located (directory). After saving the file with nano just now, since there is no directory, the file is saved in the current directory. We can query the current directory where Shell is located with the following command:
$pwd
The display is:
/ home/pi
All directories can be traced to one source, the root directory (root directory). There is a home directory under the root directory and a pi directory under home. Our current working directory is this pi directory.
Files in a directory cannot be renamed. Therefore, if you add a file name to a directory such as / home/pi, the file is uniquely identified. This is called the path to the file (path). For example:
/ home/pi/test.txt summary
This article introduces nano, an easy-to-use text editor under Linux, and common file commands.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.