First, homework (exercise) content:
1. Summarize the use of the commands involved in this course and show the relevant examples;
2. Summarize basic regular expressions and extended regular expressions
3. Display the lines in the/etc/passwd file that end with bash
grep "Bash\>"/etc/passwd
4. Display the two-digit or three-digit number in the/etc/passwd file
grep--color=auto "\<[0-9]\{2,3\}\>"/etc/passwd
5. Display lines with ' LISTEN ' followed by 0, one or more whitespace characters in the ' Netstat-tan ' command result
Netstat-tan | grep--color=auto "listen[[:space:]]*$"
6. Add user bash, Testbash, basher, and Nologin user (Nologin user's shell is/sbin/nologin), then find the same line in the/etc/passwd file as the user name and its shell name
grep "^\ ([[: Alnum:]]\{1,\}\) \>.*\<\1$"/etc/passwd
7. Display the default shell and UID of root, CentOS, or User1 user on the current system (please create these users beforehand, if not present)
Grep-e "^ (centos|user1|root) \>"/etc/passwd | Cut-d:-f3,6
8, find a word in the/etc/rc.d/init.d/functions file (the middle of the word can be underlined) followed by a set of parentheses line
grep "\<[[:alpha:]]*[_]*[[:alpha:]]*\> ()"/etc/rc.d/init.d/functions
9, use echo to output a path, and then egrep find its path base name; Further use Egrep to remove its directory name
echo/etc/rc.d/init.d/functions | Egrep-o "[^/]*$"
echo/etc/rc.d/init.d/functions | Egrep-o "[^/]*/[^/]*$" | Egrep-o "^[^/]*"
10. Find the number between 1-255 in the result of ifconfig command execution
Ifconfig | Egrep--color=auto "\< ([1-9]|[ 1-9][0-9]| [1-9] [0-9] {2}|2[0-4][0-9]|25[0-5]) \> "
Day 2 (8.27) jobs