1 , find a line in the/etc/rc.d/init.d/functions file followed by a set of parentheses, such as: Hello ();
[[email protected] ~]# grep--color=auto ' \<[[:alpha:]]\+\> () '/etc/rc.d/init.d/functionscheckpid () {daemon () { Killproc () {Pidfileofproc () {Pidofproc () {status () {success () {failure () {passed () {warning () {=} () {strstr () { Confirm () {
2.Use the echo command to output an absolute path, using grep to remove its base name;
[Email protected] ~]# echo '/etc/rc.d/init.d/functions ' | GREP--COLOR=AUTO-E-O ' [^/]+$ ' functions
Extension: Take out its path name
[Email protected] ~]# echo '/etc/rc.d/init.d/functions ' | Grep--color=auto-o ' ^\/.*\/'/etc/rc.d/init.d/
3, find out the results of the ifconfig command between 1-255 numbers;
[Email protected] ~]# Ifconfig | grep--color=auto-e-O ' \< ([1-9]|[ 1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]) \> ' 291921682041921682025525525525564186127125511281
4, find the current system does not belong to the main or group of files;
[[Email protected] ~]# find / \ ( -nouser -o -nogroup \) - exec ls-lh {} \; Total dosage 0 total dosage 0-rw-r--r--. 1 1005 distro 18 10 Month 16 2014/home/mandriva/.bash_logout-rw-r--r--. 1 1005 distro 124 10 Month 16 2014/home/mandriva/.bashrc-rw-r--r--. 1 1005 distro 176 10 Month 16 2014 /home/mandriva/.bash_profile Total dosage 4.0kdrwxr-xr-x. 2 1005 distro 1.0k 8 month 18 2010 extensionsdrwxr-xr-x. 2 1005 distro 1.0k 8 Month 18 2010 plugins Total dosage 0 total dosage 0find: "/PROC/3802/TASK/3802/FD/5": no file or directory find: "/ PROC/3802/TASK/3802/FD/5 ": does not have that file or directory find: "/PROC/3802/TASK/3802/FDINFO/5 ": does not have that file or directory find: "/PROC/3802/TASK/3802/FDINFO/5": does not have that file or directory find: "/PROC/3802/FD/5": does not have that file or directory find: "/proc/ 3802/FD/5 ": does not have that file or directoryfind: "/PROC/3802/FDINFO/5": does not have that file or directory find: "/PROC/3802/FDINFO/5": does not have that file or directory-rw-r-----. 1 27 27 0 8 month 3 2016 /var/log/mysqld.log Total dosage 0- RW-RW----. 1 1005 mail 0 12 Month 2501:22 /var/spool/mail/mandriva-rw-rw-r--. 1 root 3004 0 2 month 7 23:12 /tmp/test1-rw-rw-r--. 1 3004 root 0 2 month 7 23:12 /tmp/test2-rw-rw-r--. 1 3004 3004 0 2 Month 7 23:12 /tmp/test
[[email protected] ~]# find / \ ( -nouser -o -nogroup \) -a -atime-3 -exec ls -lh {} \; Total dosage 0 Total dosage 0 Total dosage 4.0kdrwxr-xr-x. 2 1005 distro 1.0k 8 month 18 2010 Extensionsdrwxr-xr-x. 2 1005 distro 1.0k 8 month 18 2010 plugins Total dosage 0 total dosage 0find: "/PROC/3841/TASK/3841/FD/5": not have that file or directory find: "/proc/3841/task/3841/fdinfo /5 ": does not have that file or directory find: "/PROC/3841/FD/5 ": does not have that file or directory find: "/PROC/3841/FDINFO/5 ": No that file or directory total usage 0-rw-rw-r--. 1 root 3004 0 2 month 7 23:12 / Tmp/test1-rw-rw-r--. 1 3004 root 0 2 Month 7 23:12 /tmp/ Test2-rw-rw-r--. 1 3004 3004 0 2 Month 7 23:12 /tmp/test
5.Find all files that are larger than 1M in/etc directory and are of normal file type;
[Email protected] ~]# find/etc-size +1m-type f-exec ls-lh{} \;-rw-r--r--. 1 root root 2.1M August 3 2016/etc/gconf/gconf.xml.defaults/%gconf-tree.xml-rw-r--r--. 1 root root 7.8M August 3 2016/etc/selinux/targeted/modules/active/policy.kern-rw-r--r--. 1 root root 7.8M August 3 2016/etc/selinux/targeted/policy/policy.24
6, find/etc/init.d/directory, all users have execute permission, and other users have write permission files;
[Email protected] ~]# touch/etc/init.d/test; chmod u+x,g+x,o+xw/etc/init.d/test; Find/etc/init.d/-perm-113-exec ls-lh {} \;; Rm-rf/etc/init.d/test-rwxr-xrwx. 1 root root 0 February 8 05:58/etc/init.d/test
7.Find files whose contents have been modified and not rooted or Hadoop for the last week in/etc directory;
[Email protected] ~]# Useradd jady; Useradd Hadoop; Touch/etc/test; Chown Jady/etc/test; echo ' Test ' >/etc/test; find/etc/\ (-type f-a-mtime-7-a-not \ (-user root-o-user hadoop \) \)-exec Ls-lh {} \; Rm-rf/etc/test; Userdel-r Jady; Userdel-r Hadoop-rw-r--r--. 1 jady Root 5 February 8 06:27/etc/test
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/; Ll-h/tmp/rc.sysinit-rwxr-xr-x. 1 root root 20K February 8 22:44/tmp/rc.sysinit[[email protected] ~]# vim/tmp/rc.sysinit:%[email protected]^[[: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:%[email protected]^#[[:space:]]\[email protected]@g
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:%[email protected][email protected][email protected]:% [Email protected] [Email protected] [Email protected]
one, weekly 2,4,6 backup/var/log/messages files to/backup/messages_logs/directory, saved filenames like messages-20161202
[[email protected] ~]# CRONTAB-L30 0 * * 2,4,6 [-d/backup/messages] | | /bin/mkdir-pv/backup/messages >/dev/null &&/bin/cp/var/log/messages/backup/messages/messages\-$ (/bin/ Date +\%y\%m\%d) [[email protected] ~]# ll-h/backup/messages/total usage 260k-rw-------. 1 root root 259K February 9 00:30 messages-20170209
everytwo hours per day, take all the information in the current system/proc/meminfo file to the/stats/memory.txt file
[[email protected] ~]# CRONTAB-L50 */2 * * * [-f/stats/memory] | | /bin/mkdir-pv/stats/memory >/dev/null &&/bin/grep--color=auto-i "^s"/proc/meminfo >>/stats/memory . Txt[[email protected] ~]# ll/stats/memory.txt-rw-r--r--. 1 root root 196 February 9 00:50/stats/memory.txt
Write a script to create 10 user user10-user19, password and user name;
[[email protected] ~]# vim useradd.sh 1 #!/bin/bash 2 # Program: 3 # Create 10 accounts user10 to User19, with the same password as the account name; 4 # history: 5 # 2017-02-08 jady 1.0 6 7 path= /bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin 8 export path 9 10 # 1, non-admin account when creating an account alert to exit; 11 if [ ! $UID -eq 0 ] ; then 12 echo "Sorry, Only Admin account can create user! " 13 exit 1 14 fi 15 16 # 2, cycle create account User10 to user19; 17 for index in ' seq 10 1 19 ' ; do 18&nBsp; if id user$index &> /dev/null ; then 19 read -p "user$index account already exists in the system, delete re-create (y/n)?" username 20 if [ $username = "Y" ] ; then 21 userdel -r user$index 22 if [ $? -eq 0 ] ; then 23 &nbSp; useradd user $index 24 if [ $? -eq 0 ] ; then 25 echo "user$ Index " | passwd --stdin user$index &> /dev/null 26 echo "Original user$index account with home directory has been deleted, while creating new user$index account; " 27 fi 28 fi 29 else 30 echo "Retain original user$index account information;" 31 fi 32 else 33 useradd user$index 34 if [ $? -eq 0 ] ; then 35 echo "User$index" | passwd -- stdin user$index &> /dev/null 36 echo "user$index account creation success! " 37 fi 38 fi 39 done [[email protected] ~]# bash -n useradd.sh [[email protected] ~]# useradd User10 ; useradd user18 ; bash useradd.shuser10 account already exists in the system, delete re-create (Y/N)? N Retain original user10 account information;user11 account creation success! user12 Account creation Success! user13 Account creation Success! user14 Account creation Success! user15 Account creation Success! user16 Account creation Success! user17 Account creation Success! user18 account already exists in the system, delete re-create (y/n)? Y original user18 account together with home directory has been deleted, while creating new user18 account;user19 account creation success!
Linux+python Operation Course 4th--Marco--3rd time (20170212)