In addition to being an interpreter, the shell is a high-level programming language with variables, keywords, and a variety of control statements.
Command history
History displays a list of historical commands, including its own
History 50 shows the last 50 lines of historical commands
/ECT/PASSWD User account information
/etc/shadow Optional Encrypted password file
/etc/passwd-/etc/passwd Backup files
/etc/group define a text file for a group on the system
/etc/gshadow the shadow of a group file
ID prints the true and valid user and group IDs
Id-u only valid user IDs are printed
Which: Displays the directory where the system command is located, directly to the absolute path of this command, while viewing the directory where the command is located, you can also see the command alias
Whereis: Displays the directory where the command is located and the path to the command's help document, and when you view the directory where the command is located, you can also see where the command's help document is located
Locate: Find files and directories a lot faster than find
Find: is a generic find File command that can be used to find all the files that are located on the path
grep: Use regular expressions to search for text and print matching lines
-N indicates the column number before displaying the column that conforms to the template style.
-e Converts the template style to normal notation to use
Gimp
Display file directory information, details, time output according to ISO standard
Truncate the first and eighth fields of the previous instruction with a space separator
Gzip
It can be used to compress large, less-used files to conserve disk space, and it can be combined with the tar command to form a compressed file format in the Linux operating system. There are two benefits, awareness can reduce the space, and the second is to transfer files over the network, you can reduce the transmission time.
Find files that start with D and count the number of rows
Add a new user
(4) write the corresponding shell command as required
① Search for files under directory/usr/include signal.h exists (hint: find command)
② finds the row containing the Bufsiz in all files in the/usr/include directory and displays the line number. Requirements: Only the found results are displayed on the screen and the error messages are filtered. (Tip: ① uses grep and wildcard characters *;② to leverage error message redirection and special device files/dev/null)
③ in the user name password file/etc/passwd to find the login shell for bash user information record, and display the line number 3rd page/Total 5 page (hint: use grep and $ in regular expression)
④ intercepts the 1th column (group name) and 3rd column (group ID) from the/etc/group file and sorts it by the size of the group ID number from small to large. (Hint: Use cut, pipe line and sort command in combination)
(5) Experience awk, sed usage: Execute commands sequentially to observe execution results
①cp/etc/apt/sources.list T1; Less T1
②sed-e "s/#.*//g" T1
③sed-e "s/#.*//g" T1 | awk ' {if (length! = 0) Print $} '
④tail-5/etc/passwd | Awk-f: ' {print '} '
⑤tail-5/etc/group | Tee T2 awk ' begin{print ' file t2} {print ' line ' NR ': ' $} END {print ' over '} ' T2
(6) Check the network or Help to experience command curl and wget usage.
1. Curl (File Transfer tool)
Common parameters are as follows:
-c,--cookie-jar: Writing a cookie to a file
-b,--cookie: Reading cookies from a file
-c,--continue-at: The breakpoint continues to pass
-d,--data:http Post Mode transfer data
-d,--dump-header: Writing header information to a file
-f,--from: Analog HTTP expression submission data
-s,--slient: Reduce output information
-o,--output: outputting information to a file
-o,--remote-name: According to the file name on the server, there is a local
--l,--head: Return header information only
-u,--user[user:pass]: Set HTTP authentication user and password
-t,--upload-file: Uploading Files
-e,--referer: Specifying a reference address
-x,--proxy: Specify proxy server address and port
-w,--write-out: Output Specified format content
--retry: Number of retries
--connect-timeout: Specifies the maximum time to attempt a connection/s
2. wget (file Download tool)
Common parameters are as follows:
2.1 Startup Parameters
-v,--version: Show version number
-h,--help: View Help
-b,--background: Boot to background execution
2.2 Logging and input file parameters
-o,--output-file=file: Write records to File
-a,--append-output=file: Append records to File
-i,--input-file=file: Read URL from file to download
2.3 Download Parameters
-bind-address=address: Specify local use Address
-t,-tries=number: Set maximum number of attempted connections
-c,-continue: Then download the files that are not finished downloading
-o,-output-document=file: Write download to file
-spider: Do not download files
-T,-TIMEOUT=SEC: Setting response time-out
-w,-wait=sec: Interval between two attempts
--limit-rate=rate: Limit Download rate
-progress=type: Setting the progress bar
2.4 Directory Parameters
-p,-directory-prefix=prefix: Save the file to the specified directory
2.5 http Parameters
-http-user=user: Setting the HTTP user name
-http-passwd=pass: Setting the HTTP password
-u,--user-agent=agent: Disguise Proxy
-no-http-keep-alive: Turn off the HTTP active link and turn it into a permanent link
-cookies=off: Do not use cookies
-load-cookies=file: Loading cookies from file files before starting a session
-save-cookies=file: Save cookies to file at end of session
2.6 FTP Parameters
-PASSIVE-FTP: Default value, using passive mode
-ACTIVE-FTP: Using Active mode
2.7 Recursive download exclusion parameters
-a,--accept=list: Semicolon splits the list of downloaded extensions
-r,--reject=list: Semicolon split List of extensions not being downloaded
-d,--domains=list: Semicolon splits the list of downloaded domains
--exclude-domains=list: Semicolon split List of domains not being downloaded
3. Write a shell script that is executed in 4 different ways (see Chapter 4th, Textbook/Courseware).
Practice A
Practice II
Experimental three---shell programming