Zy-2015-08-27

Source: Internet
Author: User
Tags egrep

Summarize the methods and examples of the commands involved in this course, summarize basic regular expressions and extended regular expressions to display lines ending in bash in the/etc/passwd file
Egrep ' bash$ '/etc/passwd

650) this.width=650; "class=" AlignCenter "title=" 1.png "src=" HTTP://STATIC.MOLLOC.COM/LINUX/IMGS/ZY-2015-08-27/1. PNG "alt=" command "style=" border:0px;vertical-align:middle;margin:0px auto;height:auto;text-align:center; "/>

Displays the two-digit or three-digit number in the/etc/passwd file
Egrep ' \<[[:d igit:]]{2,3}\> '/etc/passwd

650) this.width=650; "class=" AlignCenter "title=" 2.png "src=" HTTP://STATIC.MOLLOC.COM/LINUX/IMGS/ZY-2015-08-27/2. PNG "alt=" command "style=" border:0px;vertical-align:middle;margin:0px auto;height:auto;text-align:center; "/>

Show netstat -tanLine ending with ' LISTEN ' followed by 0, one, or more whitespace characters in the command result
Netstat-nat | Egrep ' \<listen[[:blank:]]* '

650) this.width=650; "title=" 3.png "src=" http://static.molloc.com/linux/imgs/ZY-2015-08-27/3.png "alt=" command " style= "border:0px;vertical-align:middle;margin:5px 0px;height:auto;"/>

Add user bash, Testbash, basher, and Nologin user (Nologin the user's shell is/sbin/nologin), and then find the row in the/etc/passwd file that has the same user name as its shell name
Egrep ' ^ ([[:alnum:]]*\>). *\1$ '/etc/passwd

650) this.width=650; "class=" AlignCenter "title=" 4.png "src=" HTTP://STATIC.MOLLOC.COM/LINUX/IMGS/ZY-2015-08-27/4. PNG "alt=" command "style=" border:0px;vertical-align:middle;margin:0px auto;height:auto;text-align:center; "/>

Displays the default shell and UID for root, CentOS, or User1 users on the current system (please create these users beforehand, if not present)
Egrep ' ^ (centos|user1|root) '/etc/passwd | Cut-d:-f3,7

650) this.width=650; "class=" AlignCenter "title=" 5.png "src=" HTTP://STATIC.MOLLOC.COM/LINUX/IMGS/ZY-2015-08-27/5. PNG "alt=" command "style=" border:0px;vertical-align:middle;margin:0px auto;height:auto;text-align:center; "/>

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 on the line
Egrep ' ([[: Alpha:]]|_) +\ (\) '/etc/rc.d/init.d/functions

650) this.width=650; "class=" AlignCenter "title=" 6.png "src=" HTTP://STATIC.MOLLOC.COM/LINUX/IMGS/ZY-2015-08-27/6. PNG "alt=" command "style=" border:0px;vertical-align:middle;margin:0px auto;height:auto;text-align:center; "/>

Use echo to output a path, then egrep to find its path base name, and further use Egrep to remove its directory name
    1. Egrep . ..//todo


Find the number between 1-255 in the ifconfig command execution result
Ifconfig | Egrep ' \< (1?[ 1-9]{1,2}|2[0-5]{2}) \> '

650) this.width=650; "class=" AlignCenter "title=" 8.png "src=" HTTP://STATIC.MOLLOC.COM/LINUX/IMGS/ZY-2015-08-27/8. PNG "alt=" command "style=" border:0px;vertical-align:middle;margin:0px auto;height:auto;text-align:center; "/>


This article is from the "Robot" blog, make sure to keep this source http://molloc.blog.51cto.com/1143037/1689701

Zy-2015-08-27

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.