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;
A. Adding a piece of hard disk
#fdisk/dev/sdb
B. Formatting and creating a file system type
#mkfs. ext4/dev/sdb1
#blkid/DEV/SDB1
C. Configure/etc/fstab to implement/DEV/SDB1 boot automatically mount to/data
#mkdir/data
#vim/etc/fstab
Add the following content
/dev/sdb1/data EXT4 Defaults 0 0
#mount-a implementation will take effect without restarting
D. Restart test is automatically mounted
#shotdown-R Now
#mount (see if Mount succeeded)
2, display the ' Netstat-tan ' command results with ' LISTEN ' followed by 0, one or more blank characters end of the line;
A. #netstat-tan | Egrep "listen[[:sapce:]]{0,}$" |wc-l
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;
A. #useradd nginx;useradd zabbix;useradd tomcat;useradd hadoop;useradd-s/sbin/nologin nologin
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;
A. #grep-O "[_[: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);
A. #echo "/etc/rc.d/init.d/functions" | Egrep-o "\<[[:alnum:]]+\>$"
B. #echo "/etc/rc.d/init.d/functions" | Egrep-o "^[/].*[/]"
6. Find all files that are not root, bin or hadoop under the/usr directory;
A. #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;
A. #find/-nouser-a-nogroup-atime-7-ls
B. #find/etc-type f-size +20k-exec du-sh {} \;
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.
A. #mkdir-pv/test/data
#groupadd It;useradd Liu;useradd Wei;
#chown: It/test/data;chmod g+ws/test/data;chmod o+t/test/data
#echo "123456" | passwd--stdin Liu
#echo "123456" | passwd--stdin Wei
#su-liu
#cd/test/data;mkdir Liu;ls-l
#su-wei
#cd/test/data;mkdir Wei;ls-l;rm-rf Liu
#su-liu
#cd/test/data;mkdir Liu;ls-l;rm-rf Wei//verification successful
Linux OPS Practice case-December 20, 2015-December 31 (first time)