How to view the help files of commands and system configuration files in Linux?

Introduction: Review of the last issue

    The previous chapter explained how to quickly find files and how to find the location of a command, so this chapter will talk about how to view the command's help documentation . In Linux commands, we will not talk about every command. What should we do if we encounter commands that we have not seen before ? It is recommended that you do not ask your seniors first, so that you will not be impressed. The key is to find the answer by yourself . This is like a problem encountered when developing a program. Look at those great gods who are very good at writing code. When encountering problems, they usually solve them by themselves, which not only improves their self-learning ability, but also makes themselves more impressive.

1. man command

        1.1 View command help documentation

             In our Linux system, what should we do if we encounter a command that we have never seen before? There are many ways: 1. You can choose to go to Baidu to find the answer. 2. You can ask the gods around you. 3. You can also check the command help documents in Linux by yourself. Everything depends on your own food and clothing! Then let's talk about how to view the command help documentation in linux.

              Command format: man command name

              Let's first use the man command to view the ls command we often use (Figure 1). Note: The man command calls the more or less browsing method by default. If you are not sure about the browsing method, please see the previous tutorial. The help documents in linux are all in English, so everyone can't do it. Even if we download a dictionary, we have to learn to try it.

            Learn to pick and focus

             Of course, not all of these contents must be read. When we encounter an unknown command, what we most want to know is what this command is used for . In fact, we only need to check a simple statement under NAME. Probably know. Let's look at Figure 2, list directory contents (list directory contents), English really can't be translated by Baidu. We can see what this command is for by looking at the next sentence of NAME. The next step is to see what options this command has (Figure 3). The -a option in ls has been mentioned in the previous chapter. All files in the listed directory also include hidden files (files starting with . are hidden files).

                


        1.2 View the configuration file help documentation

            Note: When man comes to view the help document of the configuration file, the name of the configuration file is added directly after the man. Do not write it as a path. This is not acceptable.

            Then we look at the help documentation of the configuration file mainly in two places:

             See what is saved in the modified configuration file.

             Let's look at a system file "/etc/services", what does this file save? Let's look at Figure 1, and also look at the sentence contained under NAME to know what this configuration file is saved. Internet network services list (Internet service list), everyone can see it clearly. Therefore, it is better for everyone to learn more by themselves, and it is not particularly difficult.

              Check out the format in the configuration file.

             In our linux system configuration file, no matter how messy the format he saves, there must be a rule. When we look at the configuration file help document and scroll down, we will see a line similar to this, which generally describes the format of the configuration file.

             service-name: service name, port/protocol: port/protocol, [aliases ...]: generally corresponds to an alias

             Let's take a look at the "/etc/services" configuration file. (Figure 3) shows a one-to-one correspondence with the formats we looked at earlier. (# stands for comments)

              In the Linux system, for example, the command "passwd" is not only a command, but also a configuration file. If you use man passwd to view the default command help document

             We use the whereis command to view (Figure 4). Whereis can not only find the location of the command, but also the location of the configuration file (mentioned in the previous course). Here, you need to know about the help documents displayed by whereis. One is "passwd.5.gz" and the other is "passwd.1.gz". Here, 1 is the command help and 5 is the configuration file help.

              man 5 passwd //Represents the need to view the help documentation of the configuration file passwd.

              man 1 passwd or man passwd //represents the need to view the help document of the command, 1 can be omitted or not written, and the default view is the help document of the command.

   

2. Additional help commands

        2.1 View the main help information of the command

            Command: whatis command to see

            This command will display the main information you need to view the command, mainly to see what this command is used for (Figure 1). This makes it very clear what this command does, but we need to pay attention to a problem. When I use the whatis command on other linux servers, it may prompt " nothing  appropriate ", which is a problem with different versions of linux. We just need to run "mandb", update it, and it's ready to use (Figure 2).

             

      2.2 View command option information

         Command: command to view --help 

         当我们只想查看一个命令所拥有的选项的时候,可以使用--help来查看。       

         

      2.3 查看配置文件主要的帮助信息    

        命令:apropos 配置文件名称

        查看一个配置文件的主要帮助信息

        

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325538468&siteId=291194637