You get a bonus - 1 coin for daily activity. Now you have 1 coin

3 - Linux Help - man

Lecture



In the last lecture, we looked at loading the Linux operating system. We already know the main steps that a computer goes through with the operating system from the moment you press the power button to the time you register in the system. I also recall that we will work in text mode, so we switch to a text-based virtual console and register in the system. After registration, we get to the command interpreter or shell - bash . The shell has a lot of possibilities, for the time being it’s enough to understand that this is an environment that receives, processes and issues the results of commands that we send to the operating system. The shell looks like it is shown in Figure 1.

  3 - Linux Help - man

Picture 1

What is to the left of the cursor is called an invitation to enter commands. If the prompt ends with a $ character, then you are registered in the system as a regular user. If the prompt ends with # , this means that the commands will be executed on behalf of the administrator (superuser, “root”). Let's try to type a few commands in the shell and look at the results.

We type a comma *** in date and press the Enter key. You will see the current time and date on the screen. If you enter the *** at the hostname , you will get the name of your computer. A com *** and pwd will show in which directory we are currently located. At the exit command, we will exit the shell and we will need to register again (enter the username and password).

I also want to draw attention to the Tab key, which allows you to add commands, file names and parameters. For example, type the beginning of the shut command and press the Tab key. Do you see shut automatically added to shutdown ? This addition works if there is only one option to continue the dialed piece of the command. If you type, for example, if and press Tab , then nothing will be displayed as there are several commands starting with if . To display these options, you need to click Tab again. If there are a lot of options, we will be asked if we want to see all the options. Without entering any commands, press the Tab key twice and the system will ask if we want to see all the commands? This way you can find out the total number of commands in the system (see Figure 2).

  3 - Linux Help - man

Figure 2

As you can see in the picture, the system knows 2448 commands! And that they all need to know? Of course not. It is enough to know the main teams (about a hundred) and know where and how to find information about the rest. Before we go further let's consider several commands for displaying information. To display the contents of the file on the screen allows the com *** and cat .

igor @ adm-ubuntu: ~ $ cat /etc/event.d/tty1

Result:

# tty1 - getty
#
# This service maintains a getty on tty1 from the point the system is
# started while it is shut down again.

start on stopped rc2
start on stopped rc3
start on stopped rc4
start on stopped rc5

stop on runlevel 0
stop on runlevel 1
stop on runlevel 6

respawn
exec / sbin / getty 38400 tty1

After executing this command, the file contents will be displayed on the screen. Convenient for small text files, the contents of which fit on the screen. There is also a com *** and tac ( cat - vice versa), which allows you to output the contents of the file in reverse:

igor @ adm-ubuntu: ~ $ tac /etc/event.d/tty1
exec / sbin / getty 38400 tty1
respawn

stop on runlevel 6
stop on runlevel 1
stop on runlevel 0

start on stopped rc5
start on stopped rc4
start on stopped rc3
start on stopped rc2

# started while it is shut down again.
# This service maintains a getty on tty1 from the point the system is
#
# tty1 - getty

The cat command is inconvenient when displaying large files that do not fit on one screen. Therefore, there is also a *** more . This com *** produces text in portions, when you press the Enter key, line by line, and when you press the space key, page by page. But today there is a more advanced com *** a - less .

less is already a mini-browser of its own (viewer, i-viewer) for displaying searchable files and other useful functions. Open any text file, for example /etc/bash.bashrc :

less /etc/bash.bashrc

The test will open in the less . Immediately I will say: to exit less, you need to press the q key. In less , you can use the navigation keys to move through the text (up-down, left-right, PgUp, PgDown), search for text, navigate through the words found, and much more. To perform a search you need to press the / or ? then without the space, search for the word and press the Enter key. / search word - the search will be conducted down from the current screen, and the search word - up from the current screen. If the text is large and there are a lot of searched words or they are scattered throughout the text, then using the n and N keys, you can quickly navigate through the words found. n - move up the text, N - move down. If, while in the elevator, to press the h key, the program help will open. The help will also open with the help of the lesster, therefore, to close the help, press the q key.

Now let's move on to the man command. Kom *** and man allows you to display help about all com on the system *** ah. Displays information using the less caper, so we’ve stopped at it in more detail. Dial a *** from man man - get help about help. And now press the h key and you will see help about the less command, because with its help the text about the man command is displayed. Press q to exit the less help.

Background information is grouped by section. There are 9 sections in total. You can read about them in the man manual . As an explanation, you can give an example with *** *** and the name of the file passwd . If you type man *** at man passwd , then help will be displayed on the passwd command. Type man passwd on the command line. At the very top of the help you will see the inscription passwd (1) . The number in parentheses indicates that this information refers to the first section (user commands). Scroll now to the very end of the file ( see also section - see also ) and you will see the inscription passwd (5) , which indicates that there is more information about passwd in the fifth section of the help. Exit the current help ( q ) and type the man *** pass at man 5 passwd (the number 5 indicates that the help should be displayed from the fifth section. The fifth section describes the file formats and this help does not contain information about the passwd command, which allows you to change the user's password, and about the passwd file which contains information about users.If the concept you are looking for is contained in several sections, then the information from the section with a lower number will be displayed by default.

Each help file inside has a similar structure and contains the same sections. There are a lot of sections and depending on the type of command, some sections may be present in the help, and some may not. Consider the most common in more detail.

NAME (title) - the title of the help with a brief description.

SYNIPSIS (syntax) - command syntax. Each comma *** can have options (or keys) and parameters. Options change the behavior of the command, and the parameters are what the *** will work with. For example, com *** and ls -l / home / . -l is the command key, which tells it to display additional information about directories, and / home / is the parameter passed to the command, which shows the command with which directory it needs to perform the operation. The syntax shows which command has keys, how they can be linked with each other, what parameters can be passed to the command. You must be able to read the command syntax in the man help.

[-c | -w | -tz] - such a record indicates that the keys listed through | incompatible and cannot be used together. That is, the command cannot specify the –c key and the –w key or the –t key. Must be one of them. The square brackets in which the keys are indicated indicate that the keys are not mandatory. That is, these keys can never be used in a team.

[-adhu7V] - such a record says that the keys are also optional (because in square brackets) and that the keys are compatible, that is, they can be used in any combination. For example, -ad, -a, -ahu, -h7V , etc.

When specifying the keys, it is agreed that after one “-” character there are single-letter keys, and after two “-” signs there is one key consisting of one word. Very often, single-letter keys are duplicated with keys-words. For example, -p and -parents , -v and -verbose , etc. There must be spaces between the key words; spaces between single-letter keys may not exist. Simplified general view of the command can be written as:

Com *** a [one-letter option [parameter]] [--option-word [parameter]] [parameter]

DESCRIPTION (description) - this section describes the command.

EXAMPLES (examples) - a useful section which presents practical examples of commands with the most frequently used *** keys and parameters.

OPTIONS (options, keys) - this section briefly describes the purpose of each command key.

FILES (files) - here is the location of the files somehow related to the *** *** com.

SEE ALSO (see also) - this section contains help sections on com *** files, which are related to the study and are also recommended for viewing.

There are other sections I suggest to get acquainted with them independently.

How else can I get help with Linux ? There is also a com *** a info , which is similar to man , but appeared much later and has some differences in the presentation of information. I will not dwell on the info command, just know that there is such a way to get information.

Both man and info are good when you know which command you need to get help. But you as new to Linux do not yet know what commands there are at all. Therefore, the man command has the -k option , which allows you to search for commands by keywords. For example, you want to find find commands to work with the network. The network in English will be network . Run the command line *** at man -k network . You will see a list of commands in the help of which *** is used the word network . The list is quite large and to reduce it a little, you can use the following technique. For example, in order to select from the displayed commands only those that are responsible for the configuration, you can com *** u do this:

man -k network | grep configure

Result:

ifconfig (8) - configure a network interface
iwconfig (8) - configure a wireless network interface
iwpriv (8) - configure optionals (private) wireless network parameters

So we found three commands that allow you to configure network interfaces. We’ll talk about the grep command until I say that in this example, the results of the man -k network command will be passed to the grep command , which will display only those results in which the word configure is encountered. By combining two keywords in this way, in most cases you can find the information you need. For example, man -k editor | grep text will display information about text editors that are in the system. Etc. Instead of the command man -k you can use the com *** at apropos - they are similar.

It may also be useful to com *** a man -f or its analogue whatis . It is advisable to use it when you remember the name of the team, but forgot what exactly it does. Here are some examples:

igor @ adm-ubuntu: ~ $ man -f pwd
pwd (1) - print name of current / working directory
igor @ adm-ubuntu: ~ $ man -f ls
ls (1) - list directory contents
igor @ adm-ubuntu: ~ $ man -f grep
grep (1) - print lines matching a pattern
igor @ adm-ubuntu: ~ $ whatis mkdir
mkdir (1) - make directories
igor @ adm-ubuntu: ~ $ whatis rm
rm (1) - remove files or directories

And the last com *** and which we consider - this com *** and whereis . This com *** allows you to show where the executable file of a command is located, as well as the location of the man help file for the specified command. Example:

igor @ adm-ubuntu: ~ $ whereis rm
rm: / bin / rm /usr/share/man/man1/rm.1.gz

Here / bin / rm / is the executable file, and /usr/share/man1/rm.1.gz is the help file for the rm command.

Try to determine for yourself what the ls, cd, mkdir, cp, mv, rm, rmdir commands are for . Try also to find someone *** that displays system information. And determine with which key you need to execute this com *** u, in order to display only the kernel version.

created: 2014-09-13
updated: 2021-03-13
132572



Rating 9 of 10. count vote: 2
Are you satisfied?:



Comments


To leave a comment
If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

LINUX operating system

Terms: LINUX operating system