Linux OPS Practice case-December 20, 2015-December 31 (first time)

Source: Internet
Author: User
Tags egrep

First, the actual case (practice) content
If you study Linux, want to find a portion of Linux related operations, one day you received a company to give the invitation, you came to the company interview, before the interview, OPS supervisor gave you some simple pen questions, the title is as follows:


1, the creation of a 10G file system, the type of EXT4, requires the boot can be automatically mounted to a separate data/data directory;
Step A. # FDISK/DEV/SDA
Step b. Command:n
Step c. Command action:p (primary partition)
Step d. Partition Number:3
Step e. First Cylinder:default
Step f. Last Cylinder: +10g
Step g. Command:w
Step h. # partx-a/DEV/SDA
Step i. Cat/proc/partitions
Step J. Mkfs-t Ext4/dev/sda3
Step K. mount/dev/sda3/data/
Step L. Mount-l


2, display the ' Netstat-tan ' command results with ' LISTEN ' followed by 0, one or more blank characters end of the line;
Step: Netstat-tan | grep ' listen[[:blank:]]* '


3, add user Nginx, Zabbix, Tomcat, Nologin and Hadoop users (nologin user's shell is/sbin/nologin), and then find the/etc/passwd file in the same user name and shell name of the row;
Step A. AddUser Nginx; AddUser Zabbix; AddUser Tomcat; AddUser Hadoop; Adduser-s/sbin/nologin Nologin
Step b. # grep "\<\ ([[: alnum:]]\+\>\). *\1$"/etc/passwd


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;
Step: grep "[[: Alpha:]_]*\ (() \)"/etc/rc.d/init.d/functions


5, use echo to output a path, and then egrep find its path base name; Further use Egrep to remove its directory name (note that the directory name, not the directory path);
Step A. ECHO/ETC/RC.D/INIT.D | Egrep-o "[^/]+/?$"
Step b. ECHO/ETC/RC.D/INIT.D | Egrep-o "/.*/"


6. Find all files that are not root, bin or hadoop under the/usr directory;
Step: # find/usr-not-user root-a-not-user bin-a-not-user Hadoop


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;
Step A. # Find/-nouser-a-nogroup-a-atime-7
Step b. # find/etc-size +20k-a-type F


8, create the directory/test/data, let a group of ordinary users have write permissions to it, and all the files created by the group is the directory belongs to the group; In addition, each user can only delete their own files.
Step A. # mkdir-p/test/data
Step b. # chmod 3755/test/data;
Step c. ls-l/test = result drwx-t-sr-t

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.