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;
[[email protected] ~]# dd If=/dev/zero of=/root/test bs=10m count=1000
Recorded 1000+0 read-in
Recorded the writing of 1000+0.
10485760000 gigabytes (GB) replicated, 13.7358 sec, 763 MB/s
[Email protected] ~]# losetup/dev/loop0/root/test
[Email protected] ~]# mkfs.ext4-l mydata/dev/loop0
MKE2FS 1.42.9 (28-dec-2013)
Discarding device blocks: complete
File System label =mydata
OS Type:linux
Block size =4096 (log=2)
Chunked size =4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
640848 inodes, 2560000 blocks
128000 blocks (5.00%) reserved for the Super user
First block of data =0
Maximum filesystem blocks=2151677952
Block groups
32768 blocks per group, 32768 fragments per group
8112 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Allocating group tables: complete
Writing Inode table: complete
Creating Journal (32768 blocks): complete
Writing Superblocks and FileSystem accounting information: Complete
[Email protected] ~]# Vim/etc/fstab
-bash:vim: Command not found
[Email protected] ~]# Vi/etc/fstab
#
#/etc/fstab
# Created by Anaconda on Sat 12 16:40:22 2015
#
# Accessible filesystems, by reference, is maintained under '/dev/disk '
# See mans Pages Fstab (5), Findfs (8), mount (8) and/or Blkid (8) for more info
#
/DEV/MAPPER/CENTOS-ROOT/XFS Defaults 0 0
Uuid=a75083b6-f119-487d-a023-3f98dcfd438a/boot XFS Defaults 0 0
/dev/mapper/centos-swap swap swap defaults 0 0
Label= ' MyData '/data ext4 defaults 0 0
2, display the ' Netstat-tan ' command results with ' LISTEN ' followed by 0, one or more blank characters end of the line;
Centos7 need to install Net-tools to use Netstat tool
Yum Install Net-tools
[Email protected] ~]# Netstat-tan | grep "LISTEN *$"
TCP 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
TCP 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
TCP6 0 0::: $:::* LISTEN
TCP6 0 0:: 1:25:::* LISTEN
[Email protected] ~]#
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;
[Email protected] ~]#
[Email protected] ~]# Useradd nginx
[Email protected] ~]# Useradd Zabbix
[Email protected] ~]# Useradd Tomcat
[Email protected] ~]# Useradd Hadoop
[Email protected] ~]# useradd nologin-s/sbin/nologin
[Email protected] ~]# CAT/ETC/PASSWD | grep "^\ (. *\):. */\1$"
Sync:x:5:0:sync:/sbin:/bin/sync
Shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
Halt:x:7:0:halt:/sbin:/sbin/halt
Nologin:x:1005:1005::/home/nologin:/sbin/nologin
[Email protected] ~]#
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;
[Email protected] ~]# Cat/etc/rc.d/init.d/functions | grep "[A-Z | _]()"
Systemctl_redirect () {
Checkpid () {
__pids_var_run () {
__pids_pidof () {
Daemon () {
Killproc () {
Pidfileofproc () {
Pidofproc () {
Status () {
Echo_success () {
Echo_failure () {
Echo_passed () {
Echo_warning () {
Update_boot_stage () {
Success () {
Failure () {
Passed () {
Warning () {
Action () {
Strstr () {
Is_ignored_file () {
Is_true () {
Is_false () {
Apply_sysctl () {
[Email protected] ~]#
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);
[Email protected] ~]# echo "/etc/text" | Egrep-o "[^/]*$"
Text
[Email protected] ~]# echo "/etc/text" | Egrep-o ". * *" | Egrep-o ". *[^/]"
/etc
[Email protected] ~]#
6. Find all files that are not root, bin or hadoop under the/usr directory;
[Email protected] ~]#
[Email protected] ~]# find/usr-not \ (-user root-o-user bin-o-user hadoop \)-ls
210602 0 drwx------2 polkitd root 6 June 2014/USR/SHARE/POLKIT-1/RULES.D
[Email protected] ~]#
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;
[Email protected] ~]# Clear
[[email protected] ~]# Find/-atime-7-nouser-o-nogroup
Find: '/PROC/2590/TASK/2590/FD/6 ': no file or directory
Find: '/PROC/2590/TASK/2590/FDINFO/6 ': no file or directory
Find: '/PROC/2590/FD/6 ': no file or directory
Find: '/PROC/2590/FDINFO/6 ': no file or directory
[Email protected] ~]# Find/etc-type f-size +20k
Find: Invalid-size type "K"
[Email protected] ~]# Find/etc-type f-size +20k
/etc/pki/ca-trust/extracted/java/cacerts
/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt
/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem
/etc/pki/ca-trust/extracted/pem/email-ca-bundle.pem
/etc/pki/ca-trust/extracted/pem/objsign-ca-bundle.pem
/etc/pki/nssdb/cert8.db
/etc/udev/hwdb.bin
/etc/services
/etc/sysconfig/network-scripts/network-functions-ipv6
/etc/ssh/moduli
/etc/dnsmasq.conf
/etc/lvm/lvm.conf
/etc/selinux/targeted/contexts/files/file_contexts
/etc/selinux/targeted/modules/active/base.pp
/etc/selinux/targeted/modules/active/file_contexts
/etc/selinux/targeted/modules/active/file_contexts.template
/etc/selinux/targeted/modules/active/modules/apache.pp
/etc/selinux/targeted/modules/active/modules/init.pp
/etc/selinux/targeted/modules/active/modules/staff.pp
/etc/selinux/targeted/modules/active/modules/sysadm.pp
/etc/selinux/targeted/modules/active/modules/unprivuser.pp
/etc/selinux/targeted/modules/active/modules/virt.pp
/etc/selinux/targeted/modules/active/modules/xguest.pp
/etc/selinux/targeted/modules/active/modules/xserver.pp
/etc/selinux/targeted/policy/policy.29
/etc/openldap/certs/cert8.db
/etc/postfix/access
/etc/postfix/header_checks
/etc/postfix/main.cf
[Email protected] ~]#
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
Chmod-r 1774/test/data
This article from the "Smart Young Planck" blog, declined to reprint!
Linux Practical Case-1