Week six Homework

Source: Internet
Author: User
Tags gpg

Content of this week's job:

1. 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;

For:

[Email protected] ~]# cp/etc/rc.d/rc.sysinit/tmp/[[email protected] ~]# sed-i ' s/\ (^[[:space:]]\)/#\1/g '/tmp/rc.sysi Nit

2, copy/boot/grub/grub.conf to/tmp directory, delete the blank character of the beginning of the/tmp/grub.conf file;

For:

[[email protected] ~]# cp /boot/grub/grub.conf /tmp/[[email protected] ~]#  sed  -i  ' s/^[[:space:]]\+//g '  /tmp/grub.conf[[email protected] ~]#  cat /tmp/grub.conf # grub.conf generated by anaconda## note that  you do not have to rerun grub after making changes to  this file# notice:  you have a /boot partition.  this  means that#          all kernel and  initrd paths are relative to /boot/, eg.#           root  (hd0,0) #          kernel  /vmlinuz-version ro root=/dev/mapper/VolGroup-lv_root#           initRd /initrd-[generic-]version.img#boot=/dev/sdadefault=0timeout=5splashimage= (hd0,0)/grub/ splash.xpm.gzhiddenmenutitle centos 6  (2.6.32-642.el6.x86_64) root  (hd0,0) kernel / Vmlinuz-2.6.32-642.el6.x86_64 ro root=/dev/mapper/volgroup-lv_root rd_no_luks lang=en_us. utf-8 rd_no_md rd_lvm_lv=volgroup/lv_swap sysfont=latarcyrheb-sun16 crashkernel=auto  rd_lvm_lv=volgroup/lv_root  keyboardtype=pc keytable=us rd_no_dm rhgb  quietinitrd /initramfs-2.6.32-642.el6.x86_64.img[[email protected] ~]#

3. Remove the # and white space characters from the/tmp/rc.sysinit file that begin with # and followed by at least one white-space character

For:

[Email protected] ~]# sed-i ' s/^#[[:space:]]\+//g '/tmp/rc.sysinit

4. Add # to the beginning of the first three lines in the/tmp/grub.conf file;

For:

[[email protected] ~]# sed -i  ' 1,3s/\ (^.\)/#\1/g '  /tmp/grub.conf [[email  protected] ~]# cat /tmp/grub.conf ## grub.conf generated by  Anaconda#### note that you do not have to rerun grub after  making changes to this file# notice:  you have a /boot  partition.  This means that#           all kernel and initrd paths are relative to /boot/, eg.#           root  (hd0,0) #           kernel /vmlinuz-version ro root=/dev/mapper/volgroup-lv_root#           initrd /initrd-[generic-]version.img#boot=/ Dev/sdadefault=0timeout=5splashiMage= (hd0,0)/grub/splash.xpm.gzhiddenmenutitle centos 6  (2.6.32-642.el6.x86_64) root  (hd0,0 ) Kernel /vmlinuz-2.6.32-642.el6.x86_64 ro root=/dev/mapper/volgroup-lv_root rd_no_luks  lang=en_us. utf-8 rd_no_md rd_lvm_lv=volgroup/lv_swap sysfont=latarcyrheb-sun16 crashkernel=auto  rd_lvm_lv=volgroup/lv_root  keyboardtype=pc keytable=us rd_no_dm rhgb  quietinitrd /initramfs-2.6.32-642.el6.x86_64.img[[email protected] ~]#

5. Change the last 0 of all enabled=0 or gpgcheck=0 in the/etc/yum.repos.d/centos-media.repo file to 1;

For:

[[email protected] ~]#  sed  ' s/enabled=0/enabled=1/g;s/gpgcheck=0/gpgcheck=1/g '   /etc/yum.repos.d/centos-media.repo   # centos-media.repo##  this repo  Can be used with mounted dvd media, verify the mount point  for#  centos-6.  you can use this repo and yum to  install items directly off the#  DVD ISO that we  Release.## to use this repo, put in your dvd and use it  with the other repos too:#  yum --enablerepo=c6-media [command]#   # or for only the media repo, do this:##  yum  --disablerepo=\* --enablerepo=c6-media [command] [c6-media]name=centos-$releasever  -  mediabaseurl=file:///media/centos/        file:///media/cdrom/         file:///media/cdrecorder/gpgcheck=1enabled=1gpgkey=file:///etc/pki/rpm-gpg/ rpm-gpg-key-centos-6[[email protected] ~]#

6, every 4 hours to perform a backup of the/etc directory, back up to the/backup directory, save the directory named Shape etc-201608300202

For:

[[email protected] ~]# mkdir/backup[[email protected] ~]# crontab-e Add */4 * * * * cp-rf/etc/backup/etc\-$ (date + "% Y%m%d%h%m ") to save the exit.

7, weekly 2,4,6 backup/var/log/messages file to/backup/messages_logs/directory, save the file name like messages-20160830

For:

[[email protected] ~]# mkdir-p/backup/messages_logs[[email protected] ~]# CRONTAB-E Add * * * * 2,4,6 cp-rf/var/log/ messages/backup/messages_logs/messages\-$ (date + "%y%m%d") saves the exit.

8, 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

For:

[[email protected] ~]# mkdir/stats[[email protected] ~]# crontab-e add 1 */2 * * * grep "^[s,s]"/proc/meminfo >>/S Tats/memory.txt Save exit.

9, working days of work time, every two hours to perform the echo "Howdy"

For:

[[email protected] ~]# CRONTAB-E Add * */2 * * 1-5 echo "Howdy" save exit.

Script Programming Exercises

10, create the directory/tmp/testdir-the current date and time;

For:

#!/bin/bashdate= ' date + '%y%m%d%h%m ' mkdir/tmp/testdir-$date

11. Create 100 empty files in this directory: file1-file100

For:

#!/bin/bashfor i in ' seq + ' do touch/tmp/$date/file$idone

12. Display the user name of the user who is located in the/ETC/PASSW D file in the first even row;

For:

Sed-n "N;p"/etc/passwd

13. Create 10 user user10-user19, password and user name;

For:

#!/bin/bashfor i in {10..19};d ouseradd "User$i" echo "user$i" |passwd--stdin User$idone

14, create 10 empty files file10-file19 in/tmp/;

For:

#!/bin/bashfor i in {10..19};d Omkdir/tmp/file$idone

15. Change the file10 and the genus to user10, and so on.

For:

#!/bin/bashfor i in {10..19};d ochown "user$i"/tmp/file$idone


Week six Homework

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.