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;

(1) Create directory data

# Mkdir/data

Create 20G partitions;

# fdisk/dev/sdb; N p;1; +20g; W


(2) format partition/DEV/SDB1

# mke2fs-t EXT4-L/DEV/SDB1


(3) Edit the/etc/fstab file, the device file/dev/sdb1, mount point/data, file system type EXT4, mount default options, dump frequency, self-Test level write to the configuration file and save


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

# Netstat-tan | Egrep "listen[[:space:]]*$"


3 , add user Nginx, Zabbix, Tomcat, Nologin, and Hadoop users (nologin user's shell is/sbin/nologin), then find out/etc/ A row in the passwd file that has the same user name as its shell name;

(1) Add User

# useradd nginx# useradd zabbix# useradd tomcat# useradd hadoop# useradd-s/sbin/nologin nologin


(2) find rows that match the criteria

# egrep "^ ([[: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;

# Cat/etc/rc.d/init.d/functions | Egrep "\<[[:alpha:]"?. *[_]?\>[([)] "


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);

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

# find/usr-not \ (-user root-o-user bin-o-user hadoop \)-ls


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-nogroup-a-atime-7-ls


# find/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.

# mkdir-p/test/data# chmod g+w/test/data# chmod g+s/test/data# chmod o+t/test/data

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.