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;
# fdisk /dev/sda Welcome to fdisk (util-linux 2.23.2). The changes will remain in memory until you decide to write the changes to disk. Think twice before you use the Write command. Command (input m get help): P disk /dev/sda:128.8 GB, 128849018880 byte,251658240 sector units = sector of 1 * 512 = 512 bytes sector size (logical/Physical):512 bytes / 512 byte i/o size (min/best):512 byte / 512 byte disk label type: DOS disk identifier:0x0000d19d Equipment boot start end Blocks Id System/dev/sda1 * 2048 1026047 512000 83 linux command (input m get help):npartition type: p primary (1 primary, 0extended, 3 free) e extendedselect (Default&nbsP;P): p area code (2-4, default 2): Start sectors (1026048-251658239, default = 1026048): Default values will be used 1026048last sector, + sector or +size{K,M,G} (1026048-251658239, default = 251658239): +10g partition 2 set to Linux type, size set to 10 gib command (input m get help): P Disk /dev/sda:128.8 GB, 128849018880 bytes,251658240 Sector units = Sector of 1 * 512 = 512 bytes sector size (logical/Physical):512 bytes / 512 bytes i/o size (min/Best):512 bytes / 512 byte disk label type: DOS disk identifier:0x0000d19d device Boot start end blocks Id System/dev/sda1 * 2048 1026047 512000 83 linux/dev/sda2 1026048 21997567 10485760 83 linux command (input m get help): wthe partition table has been altered! Calling ioctl () to re-read partitiontable. WARNING: Re-reading the partition tablefailed with error 16: device or resource is busy. The kernel still uses the old table. thenew table will be used atthe next reboot or after you runpartprobe (8) or KPARTX (8) is synchronizing the disk. format type ext4 #mke2fs -t ext4 /dev/sda2 create/data directory #mkdir /data boot automatically mount, change/ Etc/fstab configuration file: Vim /etc/fstab/dev/sda2 /data ext4
2, display the ' Netstat-tan ' command results with ' LISTEN ' followed by 0, one or more blank characters end of the line;
Netstat-tan | grep "listen[[:space:]]*$" [: space:] denotes a white space character * indicates that the previous character appears 0 or more times $ what is the end
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;
#useradd #useraddnginx#useraddzabbix#useradd Tomcat #useradd-S/sbin/nogoginnologin//-s indicates the default shell directory address is specified # Useraddhadoop#grep "\ (^[[:alnum:]]\+\>\). *\1$"/etc/passwd first filters out the user name, no special characters based on the user name [: alnum:], and the user name is in the/etc/ Passed file header field, all with the beginning of the line anchor ^, the word appears at least once \+ the final anchor \> so that you can filter out all user names, the shell name of the same filter, first put the front of the group, the middle with any content. *, the end content is consistent with the previous content: \?$, match once: \1 $
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;
#grep-e-o "^[_[:alpha:]]+\ (\)"/etc/rc.d/init.d/functions-o display the string itself \ Turn meaning
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);
MKDIR–P/DATA/PLTECHO/DATA/PLT | GREP-E-O "[^/]+$" first to indicate that the trailing slash end appears at least once:-E [^/]+$,-o indicates that only the matched string itself is displayed
6. Find all files that are not root, bin or hadoop under the/usr directory;
#find/usr-not-user root-a-not-userbin-a-not-user-hadoop#find/usr-not \ (-user root-o-user bin-o-user Hadoop \)-A: With-O: or-not: Non \ (\): Bind one or more characters together as one subject for processing
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–a–noguoup–a-atime-10–ls or Find/\ (-nouser-o-nogroup \)-a \ (-atime-10 \)-ls#find/etc-size +20k -type F–ls
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.
#mkdir-P/test/data//-p indicates that the loop is created #chmod o+w/test/data//Add Write permission to ordinary users #chmod g+s/test/data #chmod o+t/test/data
Linux Operations Practical Practice case 20151220~20151231