"Mage Job" Linux OPS practice case-December 20, 2015-December 31 (first time)

Source: Internet
Author: User
Tags create directory egrep


1 , create a 10G file system, type EXT4, require the boot can be automatically mounted to a separate data/data directory;

#选择文件系统分区所处的磁盘 # Check if there is enough space on the disk to create a 10G file system partition Fdisk-l;

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/78/DC/wKiom1aEBb2CtmS-AAAmILlumy0568.png "style=" float: none; "title=" 1.png "alt=" Wkiom1aebb2ctms-aaamillumy0568.png "/>

#创建分区fdisk/DEV/SDBN1+10GW

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/78/DA/wKioL1aEBdyQVux5AAB5jaeq9ds961.png "title=" 2.png " Style= "Float:none;" alt= "Wkiol1aebdyqvux5aab5jaeq9ds961.png"/>

#格式化并获取UUIDmkfs. ext4/dev/sdb1blkid/dev/sdb1

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/78/DC/wKiom1aEBcCTuZIwAABgy15MdeI080.png "title=" 3.png " Style= "Float:none;" alt= "Wkiom1aebcctuziwaabgy15mdei080.png"/>

#创建挂载目录/data# write/etc/fstab for boot auto mount Mkdir/dataecho "Uuid=010146af-4e90-4be0-81c1-e60445225804/data ext4 defaults 0 0" & Gt;>/etc/fstabmount-amount

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/78/DA/wKioL1aEBd6RMbg3AAA6NNCsS6A170.png "title=" 4.png " Style= "Float:none;" alt= "Wkiol1aebd6rmbg3aaa6nncss6a170.png"/>

2 , display the ' netstat-tan ' command result with ' LISTEN ' followed by 0, one or more whitespace characters end of the line;

Netstat-tan Netstat-tan | Grep-e "\<listen\>[[:space:]]*$"

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/78/DC/wKiom1aEBcGT9gL1AABVhKMwIeM918.png "title=" 5.png " Style= "Float:none;" alt= "Wkiom1aebcgt9gl1aabvhkmwiem918.png"/>

3 , add user Nginx, Zabbix, Tomcat, and Hadoop users (the Nologin 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 ;

Useradd nginx;useradd zabbix;useradd tomcat;useradd hadoop;useradd nologin-s/sbin/nologin;cat/etc/passwd | grep "^\ ([[: alnum:]]\+\>\). *\1$"

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/78/DC/wKiom1aEBcPTxmb6AACppQqJfd4278.png "title=" 6.png " Style= "Float:none;" alt= "Wkiom1aebcptxmb6aacppqqjfd4278.png"/>

4 , 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;

cat/etc/rc.d/init.d/functions | Egrep "\<[[:alpha:]]+_[[:alpha:]]+\>\ (\)"

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/78/DC/wKiom1aEBcShkHnRAAAfdDyx59A112.png "title=" 7.png " Style= "Float:none;" alt= "Wkiom1aebcshkhnraaafddyx59a112.png"/>

5 , use echo to output a path, and then egrep find its path base name, and further use Egrep to remove its directory name (note that the directory name, not the directory path);

echo "/abc/def/ghi/jkl/" | Egrep-o "[^/]+/?$" | Cut-d "/"-f1

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/78/DA/wKioL1aEBeHQDHWyAAANAp4GAmc657.png "title=" 8.png " Style= "Float:none;" alt= "Wkiol1aebehqdhwyaaanap4gamc657.png"/>

6 , look for all files that do not belong to root, bin, or Hadoop in the/usr directory;

FIND/USR-! \ (-user root-o-user bin-o-user hadoop \)-ls

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/78/DA/wKioL1aEBeKxiJkjAAAU6Y3cw2c963.png "title=" 9.png " Style= "Float:none;" alt= "Wkiol1aebekxijkjaaau6y3cw2c963.png"/>

7 , one day the system was invaded, hackers in your system to leave the Trojan file:

You now need to find all the files on the current system that are not owned by the master or group and have been visited in the last week;

In addition, it is necessary to find all files of more than 20k and type ordinary files in/etc directory;

find/-nouser-o-nogroup-atime-7find/etc-type f-size +20k

8 , Create directory/test/data, let the normal user in a group have write permission to it, and all the files created belong to the group that the directory belongs to, in addition, each user can only delete their own files.

[Email protected]~]# mkdir-p/test/data[[email protected]~]# groupadd testgroup[[email protected]~]# chown:testgroup/ Test/data/[[email protected]~]# chmod g+w/test/data/[[email protected]~]# chmod g+s/test/data/[[email protected]~]# chmod o+t/test/data/[[email protected]~]# ll-d/test/data/


650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/78/DC/wKiom1aEBcXhC3XSAAA0QUkgAXc107.png "title=" 10.png "Style=" Float:none; "alt=" Wkiom1aebcxhc3xsaaa0qukgaxc107.png "/>


"Mage Job" Linux OPS practice case-December 20, 2015-December 31 (first time)

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.