This article is based on the Liu Yan teacher's "Linux should be so learned" in personal easy to forget the reading notes, combined with personal weaknesses, may not be suitable for the vast number of netizens classmate, and hereby declare this article is only used for learning, no infringement of the meaning of copyright
That's what Linux should do. Chapter Two the novice must master command 5. wget command
The wget command is used to download the network file in the terminal, in the form of "wget [parameter] download address".
Parameters and functions of the wget command
Parameters |
function |
-B |
Background Download mode |
-P |
Download to the specified directory |
-T |
Maximum number of attempts |
-C |
Breakpoint Continuation |
-P |
Download all resources on the page, including pictures, videos, etc. |
-R |
Recursive downloads |
6. PS Command
The PS command is used to view the status of the process in the system, in the format "PS [parameters]".
Use the PS command with the Pipe technology in chapter 3rd to crawl the PID number corresponding to a specified service process. The common parameters and functions of the PS command are shown in table 2-6.
Parameters and functions of PS command
Parameters |
function |
-A |
Show all processes (including processes for other users) |
-U |
Users and other details |
-X |
Show processes with no control terminal |
8. pidof Command
The PIDOF command is used to query the PID value of a specified service process in the format "pidof [parameter] [service name]".
The process number value (PID) of each process is unique, so the PID can be used to differentiate different processes. For example, you can use the following command to query the PID of the SSHD service on this computer:
[Root@linuxprobe ~]# pidof sshd 2156 10. Killall Command
The killall command terminates all processes corresponding to a service of a specified name in the format: "killall [parameter] [process name]".
Typically, complex software service programs have multiple processes that work together to provide services to users, and it can be cumbersome to end these processes one at a time by using the Killall command to bulk end the entire process with a service program. The following is an example of a HTTPD service program to end all of its processes. Because the RHEL7 system default does not install HTTPD service program, so everyone just look at the operating process and output results, and so on after learning the relevant content and then practice.
[Root@linuxprobe ~]# pidof httpd
13581 13580 13579 13578 13577 13576
[Root@linuxprobe ~]# Killall httpd
[Root@linuxprobe ~]# pidof httpd
[Root@linuxprobe ~]# 1. Ifconfig command
The Ifconfig command is used to obtain information such as NIC configuration and network status, in the form of "ifconfig [network device] [parameters]".
Using the Ifconfig command to view the current network adapter configuration and the status of the Internet, and other information, in fact, the main view is the network card name, inet parameters after the IP address, ether parameters after the physical address (also known as MAC address), and Rx, Tx of the number of received packets and packets sent and the cumulative flow (that is, the following bold information content):
[Root@linuxprobe ~]# Ifconfig
eno16777728:flags=4163 MTU 1500
inet 192.168.10.10 netmask 255.255.255.0 broadcast 192.168.10.255
Inet6 fe80::20c:29ff:fec4:a409 Prefixlen ScopeID 0x20
Ether 00:0c:29:c4:a4:09 Txqueuelen 1000 (Ethernet)
RX Packets Bytes 3176 (3.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX Packets Bytes 4757 (4.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Lo:flags=73 MTU 65536
inet 127.0.0.1 netmask 255.0.0.0
Inet6:: 1 prefixlen 128 ScopeID 0x10
Loop Txqueuelen 0 (local loopback)
RX Packets 386 bytes 32780 (32.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX Packets 386 bytes 32780 (32.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 2 . uname command
The uname command is used to view information such as the system kernel and system version, in the form "uname [a]".
When using the uname command, information such as the kernel name, host name, kernel release, node name, system time, hardware name, hardware platform, processor type, and operating system name of the current system is generally viewed in its entirety.
[Root@linuxprobe ~]# Uname-a
Linux linuxprobe.com 3.10.0-123.el7.x86_64 #1 SMP Mon May 5 11:16:57 EDT 2017 x86_64 x86_64 x86_64 3 gnu/linux. Uptime Command
Uptime is used to view the system's load information in uptime format.
The uptime command is really great, and it can display information such as the current system time, the system's elapsed time, the number of terminals enabled, and the average load value. Average load value refers to the system in the last 1 minutes, 5 minutes, 15 minutes of the pressure situation (below the thick Information section); The lower the load value the better, as far as possible not longer than 1, in the production environment should not exceed 5.
[Root@linuxprobe ~]# Uptime
22:49:55 up min, 2 users, Load average:0.01, 0.19, 0.18 4. Free command
Free displays the amount of memory usage information in the current system, in the form "free [-h]".
To ensure that Linux systems do not suddenly go down because of resource depletion, operators need to keep an eye on the amount of memory used. When you use the free command, you can use the-h parameter to output real-time usage information for the current memory in a more humane way. Table 2-8 shows the output information after the FREE-H command is executed on the Liu Yan teacher's computer. It should be noted that the Chinese annotation in the output information is the content of the author's own additions, and the actual output has no corresponding parameter interpretation.
[Root@linuxprobe ~]# free-h 2.8 Package Compression and search command
1. Tar command
The tar command is used to package or decompress a file in the format "tar [options] [file]".
In Linux systems, there are many common file formats, the main use of which is. tar or. tar.gz or. tar.bz2 format, we don't have to worry about too many formats to remember, but most of these formats are generated by the tar command. Liu Yan will explain some of the most important parameters to make it easier for everyone to understand. The parameters of the tar command and their effects are shown in table 2-14.
Parameters and functions of the TAR command
parameter |
effect |
-C |
Create pressure Shrink file |
-X |
Undo Compressed file |
-T |
see what files are in the ZIP package |
-Z |
use gzip compression or decompression |
-j |
compress or extract with bzip2 |
-V |
Displays the process of compressing or decompressing |
-F |
destination file name |
-P |
retains the original permissions and properties |
-P |
uses absolute paths to compress |
-C |
Specifies the directory that is extracted |
First, the-c parameter is used to create the compressed file, the-x parameter is used to extract the file, so the two parameters cannot be used concurrently. Second, the-Z parameter specifies that the file be compressed or uncompressed using the gzip format, and the-J parameter specifies that the file be compressed or uncompressed using the BZIP2 format. The user uses the suffix of the file to determine what format parameter should be used for decompression. When performing some compression or decompression operations, it may take several hours, if the screen has not been output, on the one hand, you can not judge the progress of the package, on the other hand will also suspect that the computer crashed, so it is highly recommended to use the-v parameter to the user to continuously display the compression or decompression The-c parameter specifies which specified directory to extract to. The-f parameter is particularly important, it must be placed in the last parameter, representing the package name to compress or decompress. Liu Yan Teachers generally use the "TAR-CZVF Compressed package name. tar.gz the directory to package" command to package the specified file compression; the corresponding decompression command is "TAR-XZVF Compressed package name. tar.gz".
[Root@linuxprobe ~]# tar czvf etc.tar.gz/etc
Tar:removing leading '/' from member names
/etc/
/etc/fstab
/etc/crypttab
/etc/mtab
/etc/fonts/
/etc/fonts/conf.d/
/etc/fonts/conf.d/65-0-madan.conf
/etc/fonts/conf.d/59-liberation-sans.conf
/etc/fonts/conf.d/90-ttf-arphic-uming-embolden.conf
/etc/fonts/conf.d/59-liberation-mono.conf
/etc/fonts/conf.d/66-sil-nuosu.conf
.................. Omit part of the compression process information ..... ......
Next, specify the packaged compressed package file to extract into the/ROOT/ETC directory (first use the mkdir command to create the/ROOT/ETC directory):
[Root@linuxprobe ~]# Mkdir/root/etc
[Root@linuxprobe ~]# tar xzvf etc.tar.gz-c/root/etc
etc/
Etc/fstab
Etc/crypttab
Etc/mtab
etc/fonts/
etc/fonts/conf.d/
Etc/fonts/conf.d/65-0-madan.conf
Etc/fonts/conf.d/59-liberation-sans.conf
Etc/fonts/conf.d/90-ttf-arphic-uming-embolden.conf
Etc/fonts/conf.d/59-liberation-mono.conf
Etc/fonts/conf.d/66-sil-nuosu.conf
Etc/fonts/conf.d/65-1-vlgothic-gothic.conf
Etc/fonts/conf.d/65-0-lohit-bengali.conf
Etc/fonts/conf.d/20-unhint-small-dejavu-sans.conf
.................. Omit part of the decompression process information ......... Chapter Three pipe characters, redirects, and environment variables 3.1 input and output redirection
In short, input redirection refers to importing a file into a command, whereas output redirection refers to writing the data information that was originally to be printed to the screen to the specified file.
In the daily study and work, compared with the input redirection, we use output redirection frequency is higher, so the output redirection is divided into standard output redirection and error output redirection two different technologies, as well as empty write and append write two modes.
Standard input redirection (STDIN, file descriptor 0): input from the keyboard by default or from other files or commands.
Standard output redirection (STDOUT, file descriptor 1): Default output to screen.
Error output Redirection (STDERR, file descriptor 2): Default output to screen.
The symbols used in input redirection and their effects
symbols |
function |
Commands < Documents |
Standard input of a file as a command |
Commands << Delimiters |
Read from the standard input until you meet the demarcation character character stop |
Command < file 1 > file 2 |
The standard input of file 1 as a command and the standard output to file 2 |
Symbols used in output redirection and their effects
symbols |
function |
Commands > Documents |
REDIRECT standard output to a file (empty existing file data) |
Command 2> file |
REDIRECT error output to a file (empty existing file data) |
Commands >> Documents |
REDIRECT standard output to a file (appended to the previous content) |
Command 2>> file |
REDIRECT error output to a file (appended to the previous content) |
Command >> file 2>&1 or command &>> file |
Writes the standard output to the file (appended to the original content) with the error output |
For standard output patterns in redirection, you can omit file descriptor 1 from writing, and file descriptor 2 of the error output pattern must be written. Let's start with a little test. Use standard output redirection to write information about the Man Bash command to the screen to the file Readme.txt, and then display the contents of the Readme.txt file. The specific orders are as follows:
[Root@linuxprobe ~]# man bash > Readme.txt
[Root@linuxprobe ~]# Cat Readme.txt
Bash (1) General Commands Manual Bash (1)
NAME
Bash-gnu Bourne-again SHell
Synopsis
bash [options] [file]
COPYRIGHT
Bash is-Copyright (C) 1989-2011 by the free Software Foundation, Inc.
DESCRIPTION
Bash is a sh-compatible command language interpreter that executes
Commands read from the standard input or from a file. Bash also incor‐
Porates useful features from the Korn and C shells (Ksh and CSH).
Bash is intended to be a conformant implementation of the Shell and
Utilities portion of the IEEE POSIX Specification (IEEE Standard
1003.1). Bash can be configured to is posix-conformant by default.
.................. Omit part of the output information ...... .....
Input redirection is relatively unpopular, and the probability of encountering in the job is smaller. The role of input redirection is to import files directly into the command. Next, use input redirection to import the Readme.txt file to the Wc-l command, which counts the number of rows in the file.
[Root@linuxprobe ~]# Wc-l < readme.txt
2
The above command is actually equivalent to the next study of the cat Readme.txt | Wc-l of the pipe character command combination. 3.2 Pipe command character
The role of the command can also be summed up in one sentence, "The data that was originally intended to be exported to the screen as the standard input of the last command"
The command to find the restricted logged-in user is grep "/sbin/nologin"/ETC/PASSWD;
The command that counts the number of lines of text is wc-l.
Now to do is to the search command output value to the statistical command, that is to output to the screen of the user information list and then to the WC command for further processing, so just put the pipe to two commands between the command can be, specifically as follows. This is simply too convenient.
[Root@linuxprobe ~]# grep "/sbin/nologin"/etc/passwd | Wc-l
33
This pipe character is like a magic weapon, we can apply it to other different commands, such as paging to view the list of files in the/etc directory and attribute information (these content by default will be peremptorily to the screen, do not see clearly):
[Root@linuxprobe ~]# ls-l/etc/| More
Total 1400
Drwxr-xr-x. 3 Root 17:26 ABRT
-rw-r–r–. 1 root 17:36 Adjtime
-rw-r–r–. 1 root 1518 June 7 2013 aliases
-rw-r–r–. 1 root root 12288 June 09:38 aliases.db
Drwxr-xr-x. 2 Root 17:26 Alsa
Drwxr-xr-x. 2 root root 4096 June 17:31 alternatives
-RW ——-. 1 root root 541 2017 Anacrontab
-rw-r–r–. 1 root 2017 asound.conf
-rw-r–r–. 1 root root 1 2017 At.deny
Drwxr-xr-x. 2 Root 17:27 at-spi2
drwxr-x-. 3 Root 17:26 Audisp
drwxr-x-. 3 Root 17:37 Audit
Drwxr-xr-x. 4 Root 17:26 Avahi
–more–
When you modify a user's password, you typically need to enter two passwords for confirmation, which can be a very fatal flaw in writing automation scripts. By combining the pipe character with the –stdin parameter of the passwd command, we can use a single command to complete the password reset operation:
[Root@linuxprobe ~]# echo "Linuxprobe" | Passwd–stdin Root
Changing password for user root.
Passwd:all authentication tokens updated successfully.
For example, when sending e-mail, the default is interactive, we can use a combination of the pipe character command statement, the edited content with the title "packaging", and finally use this command to implement the message sent.
[Root@linuxprobe ~]# echo "Content" | Mail-s "Subject" Linuxprobe
[Root@linuxprobe ~]# Su-linuxprobe
Last Login:fri June 09:44:07 CST 2017 on:0
[Linuxprobe@linuxprobe ~]$ Mail
Heirloom Mail Version 12.5 7/5/10. Type? For help.
"/var/spool/mail/linuxprobe": 1 message 1 new
N 1 root Sun Aug 17:33 18/578 "Subject" chapter fourth vim editor and Shell command script
The commands commonly used in VIM
Command |
function |
Dd |
Delete (cut) the entire line where the cursor is located |
5dd |
Delete (cut) 5 lines starting at the cursor |
Yy |
Copy the entire line where the cursor is located |
5yy |
Copy 5 lines starting at the cursor |
N |
Displays the next string that the search command navigates to |
N |
Displays the last string that the search command navigates to |
U |
Undo the action in the previous step |
P |
Paste the previously deleted (DD) or copied (yy) data behind the cursor |
Commands available in last-line mode
command |
effect |
: w
| Save /td>
: Q |
exit |
: q! |
Force exit (discard changes to the document) |
: wq! |
Force save Exit |
: Set nu |
Show line number |
: Set Nonu |
does not display line numbers |
: Command |
to execute this command |
: integer |
jumps to the line |
: S/one/two |
replaces the first one in the row on which the current cursor is positioned with two |
: s/one/two/g |
Replaces all one of the rows of the current cursor with two |
:%s/one/two/g |
Replaces all one of the full text with two |
? string |
searches for the string from bottom to top in text |
/String |
searches for the string from top to bottom in text |