1. Find the line with a set of parentheses after a word in the/etc/rc.d/init.d/functions file, such as: Hello ();
[[email protected] ~]# grep-e "[[: Alpha:]]+\ (\) +"/etc/rc.d/init.d/functions 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 () {
2. Use the echo command to output an absolute path, using grep to remove its base name;
[Email protected] ~]# echo "/bin/bash/" | GREP-E-O "[^/]+/?$] | Cut-d/-f1bash
Extension: Take out its path name
[Email protected] ~]# echo "/bin/bash/d/" | GREP-E-O "^/.*[^/]" | GREP-E-O "^/.*/"/bin/bash/
3, find out the results of the ifconfig command between 1-255 numbers;
[Email protected] ~]# Ifconfig | GREP-E-O "[[:d Igit:]]{1,} ' | GREP-E-W "(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[ 1-9][0-9]| [1-9]) " 1921682231282552552551921682232556802029366420293671987312712556112810262262192168122125525525519216812225552547095
[[email protected] ~]# ifconfig | grep -e -w "(25[ 0-5]|2[0-4][0-9]|1[0-9][0-9]| [1-9] [0-9]| [1-9]) " inet 192.168.223.128 netmask 255.255.255.0 broadcast 192.168.223.255 inet6 fe80::20c:29ff:fe3d:6dea prefixlen 64 scopeid 0x20<link> ether 00:0c:29:3d:6d:ea txqueuelen 1000 (Ethernet) rx packets 501011 bytes 692867068 (660.7&NBSP;MIB) TX packets 157560 bytes 20813669 (19.8&NBSP;MIB) lo: flags=73<up,loopback,running> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x104, find the current system does not belong to the main or group of files;
[[email protected] ~]# Find/-nouser-nogroupfind: '/PROC/38302/TASK/38302/FD/6 ': No such file or directoryfind: '/PROC/3 8302/TASK/38302/FDINFO/6 ': No such file or directoryfind: '/PROC/38302/FD/6 ': No such file or Directoryfind: '/proc/38302/ FDINFO/6 ': No such file or directory
Further: Find files or directories that are not owned by the master or group on the current system and have been visited in the last 3 days;
[[email protected] ~]# Find/-nouser-nogroup-atime-3find: '/PROC/38312/TASK/38312/FD/6 ': No such file or Directoryfind : '/PROC/38312/TASK/38312/FDINFO/6 ': No such file or directoryfind: '/PROC/38312/FD/6 ': No such file or Directoryfind: '/P ROC/38312/FDINFO/6 ': No such file or directory
5, find all files that are larger than 1M in the/etc directory and are of the normal file type;
[[email protected] ~]# find /etc -size +1m -type f -ls69639801 3772 -rw-r--r-- 1 root root 3858924 nov 20 2015 /etc/selinux /targeted/policy/policy.29135034268 6852 -r--r--r-- 1 root root 7014922 dec 23 00:49 /etc/udev/ Hwdb.bin68629841 1336 -rw-r--r-- 1 root root 1367395 mar 5 2015 /etc/brltty/zh-tw.ctb
6, find/etc/init.d/directory, all users have execute permission, and other users have write permission files;
[Email protected] ~]# find/etc/init.d/-perm-113-type F
7. Find files whose contents have been modified and not rooted or Hadoop for the last week in/etc directory;
[Email protected] ~]# find/etc-mtime-7-not-user root-not-user hadoop-ls
8. Copy the/etc/rc.d/rc.sysinit file to the/tmp directory and add # to the beginning of the line with at least one whitespace character in the/tmp/rc.sysinit file;
[Email protected]~]# cp/etc/rc.d/rc.sysinit/tmp/[[email protected]~]# vim/tmp/rc.sysinit
In the last line mode, enter:
%s/^[[:space:]]\+/#&/g
9. Remove the # and white space characters from the/tmp/rc.sysinit file that begin with # and followed by at least one white-space character
[[Email protected]~]# vim/tmp/rc.sysinit
In the last line mode, enter:
%s/^[#][[:space:]]\+//g
10. Change the last 0 of all enabled=0 or gpgcheck=0 in the/etc/yum.repos.d/centos-media.repo file to 1;
[Email protected]~]# vim Etc/yum.repos.d/centos-media.repo
In the last line mode, enter:
%s#\ (enabled=\) [[:d Igit:]]#\11#g
%s#\ (gpgcheck=\) [[:d Igit:]]#\11#g
11, weekly 2,4,6 backup/var/log/messages file to/backup/messages_logs/directory, save the file name like messages-20161202
[[email protected] ~]# CRONTAB-E0 0 * * 2,4,6/bin/cp-a/var/log/messages/backup/messages_logs/messages-$ (date +\%Y\%m\ #do
12, every two hours every day to take the current system/proc/meminfo file in the beginning of all the information in the S./stats/memory.txt file
[Email protected] ~]# crontab-e00 */2 * * * cat/proc/meminfo |grep "^s" >>/stats/memory.txt
13, write a script to create 10 user user10-user19, password and user name;
#!/bin/bash# for I, {10..19};d o if ID user$i; then echo "user$i exists." else Useradd user$i echo "User$i" | passwd--stdin user$i fi done
This article from "The Boundless" blog, declined reprint!
Linux+python third operation of high-end operation and Maintenance class