2017-10-10linux Basics (6) Basic commands
In the previous chapter, we mainly introduced some basic Linux command and command line interface format, in Linux, the command is necessary to master some basic commands, in the future shell script, we also use these commands to handle the complex tasks of the system, then in the following chapters, We start by telling the format of the commands and how to get help with them.
The syntax format of a command
In Linux, all commands are basically syntactically formatted, as shown in the following example:
# COMMAND OPTIONS argments
These three good explanations are nothing more than commands, options and parameters, stating that the user initiated the command is to request the kernel to run a binary program as a process to manipulate the parameters, and add the option is to specify the features of the command to add and modify one, Then the command itself is an executable program file, usually a binary format of the file, it is also possible to call the shared library file, the command is divided into two categories, one is the management of the command, the other is a common command, but most of the files will be stored in the following path:
/bin,/sbin,/usr/bin,/usr/sbin,/usr/local/bin,/usr/local/bin,/usr/local/sbin
The normal and administrative commands hold the following path:
General Command:/bin,/usr/bin,/usr/local/bin Management command:/sbin,/usr/sbin/,/usr/local/sbin
In addition to some common classes and management classes and other commands, there is a shared library, before we also talked about the role of the system call, through the kernel to hide the underlying complex and differentiated hardware, so as to output a simple and unified interface, but this interface is too low, so on the system called Interface , and encapsulates a more complex component, which we call a library, so that a step closer to the person, so that in the program development directly call the function of the library, if you do not want to invoke the function of the library, can be from the system call interface to develop programs, So the shared library facilitates the development of maintenance costs and shorten the development of the time period, the shared library has two categories, one is a 32-bit library, the other is a 64-bit library, and 32-bit is not compatible with 64-bit, and vice versa is possible, then the shared library path is as follows:
Shared libraries:/lib,/lib64,/usr/lib,/usr/lib64,/usr/local/lib,/usr/local/lib64 32bit Library:/lib,/usr/lib,/usr/local/lib 64bi Library of T:/lib64,/USR/LIB64,/usr/local/lib64
Note: Not all commands have an executable file corresponding to it in a directory.
Since the command is basically an executable binary, then it has to obey the command format, for example, in common Windows, the executable file format is .exe
, and the Linux format is elf
. In the first chapter we talked about using file to parse the command format, which is not much of an introduction.
1.1 Internal commands and external commands
Now that you've covered the format of the command and the path to the command, let's look at what internal and external commands are.
The internal command is the command that comes with the shell program, and we can use BUILTIN Help to view internal commands, and the shell program is a unique program that parses the commands provided by the user.
External commands are also independent executable program files, usually filenames are command names, which are provided by environment variables.
When the user types a command or other character, the shell program is responsible for parsing the user-supplied commands, and if resolving to an external command looks from the environment variable, the environment variable is the command file that looks for the command string that the user typed from those paths. The lookup order is from left to right, and if the file corresponding to the command is found, the lookup is stopped. The name of the environment variable is $PATH
, we use echo
the echo command to view the environment variables of the $path:
# echo $PATH/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
If the check command is internal or internal, we need to use a type
command to view it in the following format:
# type COMMAND
1.2 Command options
The option of the command is to specify the running characteristics of its command, through which it can modify and add to the function of the command and change some features, usually the choice of two forms of expression, one is a long option, you can see the meaning of the name, but the long option is likely to be remembered, for example --help
, and --human-readable
, this is the long option, but it is important to note that the long option cannot be merged.
The other is short options, such as:,,, -C
-l
-d
etc., but note that some command options are not -
, if the same command uses multiple short options, you can merge most, for example: -l
, -d
merge I to be -ld
, But the short option cannot be seen as the meaning of the name.
1.3 Parameters
The so-called parameter is the command function of the object, the command for what takes effect, mainly the directory or file, but note that: different command parameters, some commands can take multiple parameters at the same time, multiple can be separated by whitespace characters, for example:
# LS-LD/VAR/ETC
Second, get the use of the command help
In Linux, whether it is query command or build services, the use of Help files will let you know the basic use of the service or command and detailed introduction to them, this is undoubtedly a great help to learn Linux, in both internal and external commands, the command-related help.
Examples of internal commands are:
# Help COMMAND
Then the external command is the use help of the self-contained brief format, and the brief help in each command will display its primary information, as shown in the following example:
# COMMAND--help
If you want to see the details and the description of the command or service, look at the command's Help manual, the manual
man
Manual, which is located in the /usr/share/man
directory, and commands are used as follows:
# Man COMMAND
The general distribution of the Man Handbook is as follows:
Section (Introduction): NAME: Description of functionality; Synopsis: Syntax format; DESCRIPTION: description; options: option; EXAMPLES: use example; AUTHOR: Author; BUGS: How to report a bug in a program; See ALSO: Reference; Synopsis (Common parameters): []: optional content; <>: Must be provided; A|b|c: multiple Choice one; : Similar content can appear more than one;
The above is the general content of the manual, and the manual is usually a compressed format of the file, and the Man Manual is a section of chapters, usually 1-9 chapters in the /usr/share/man
directory with Man1 and man2, which are related to the Man Manual chapter, chapter examples are as follows:
1, the user command; 2, System call; 3, c library call; 4, equipment files and special documents; 5, configuration files; 6, game and use help; 7, Miscellaneous; 8, System Management command tools and daemons; 9, kernel process (non-standard);
If you want to see a chapter, just follow the man command followed by a number option, the command format is:
# Man CHAPTER COMMAND
It is important to note that it does not each COMMAND
have a manual under the chapter, if you want to view a command or some other such as a library call in that section, the command format is:
# Whatis COMMAND
It is also important to note that man's execution process is in the village database to do, if you want to manually update the command:
# Makewhatis
Explain how to open the man manual after opening it:
Flip Screen: space: To the end of the file to flip a screen; B: Turn over the file header; Ctrl+d: Half-screen to the tail of the file; Ctrl+u: Turn half screen to file header; Enter: Flip a line to the end of the file; K: #g to the file header: jumps to the last line; 1G: Jumps to the file header; File search:/keyword: From the file header to the end of the file lookup, case-insensitive; Keyword: Find the file header from the end of the file; N: the same direction as the Find command; N: Opposite to the search command direction; Exit: Q:quit
Option:-m/path/to/somedir: Find the manual and open it in the specified location directory;
In addition to the local, there are help documents for getting commands online, with the command:
# info COMMAND
There are also many applications that bring their own help document path to:/usr/share/doc/app-version, file as follows:
README: Relevant information about the program; Install: Installation help; Changes: Changes in version iterations;
This article from the "Scorpio Blog" blog, reproduced please contact the author!
2017-10-10linux Basics (6) Basic commands