Linux Operations Learning-6th Week jobs

Source: Internet
Author: User

Exercises:
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;

:%[email protected]^[[:space:]]\[email Protected]#&@g

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

:%[email protected]^[[:space:]]\[email Protected]@g
3. Delete the # and whitespace characters in the/tmp/rc.sysinit file that begin with # and followed by at least one white-space character in the line;

:%[email protected]^#[[:space:]]\[email Protected]@g
4. Add # to the beginning of the first three lines in the/tmp/grub.conf file;

: 1,[email protected]*@#&@g
5. 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]\ (enabled\|gpgcheck\) [email protected]\[email protected]

6, every 4 hours to perform a backup of the/etc directory, back up to the/backup directory, the saved directory name is shaped like etc-201504020202;

0 */4 * * * root cp-r/etc//backup/etc-$ (date +%y%m%d%h%m)

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

0 0 * * 2,4,6 root cp-r/var/log/messages/backup/messages_logs/messages-$ (date +%y%m%d)
8, every two hours every day to take the current system/proc/meminfo file all the information in the beginning of S to the/stats/memory.txt file;

0 */2 * * * root grep "^s"/proc/meminfo >>/stats/memory.txt
9, working days of work time, every two hours to perform the echo "Howdy";

0 9-17/2 * * 1-5 root echo "Howdy"
Script Programming Exercises:
10, create the directory/tmp/testdir-the current date and time;
#!/bin/bash
mkdir/tmp/testdir-$ (Date +%y%m%d%h%m)

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

#!/bin/bash
for (i=1;i<=100;i++) {
touch/tmp/testdir-$ (date +%y%m%d%h%m)/file$i
}
12. Display the user name of the user who is located in the/etc/passwd file in the first even row;
#!/bin/bash
Sed-n ' n;p '/etc/passwd | Cut-d:-f1
13. Create 10 user user10-user19, password and user name;

#!/bin/bash
for (i=10;i<=19;i++) {
Useradd user$i
echo "User$i" | passwd--stdin user$i &>/dev/null
}
14, create 10 empty files file10-file19 in/tmp/;
#!/bin/bash
for (i=10;i<=19;i++) {
Touch/tmp/file$i
}
15. Change the file10 and the genus to user10, and so on.
#!/bin/bash
for (i=10;i<=19;i++) {
Chown user$i:user$i file$i
}


This article is from the "9099360" blog, please be sure to keep this source http://9109360.blog.51cto.com/9099360/1865224

Linux Operations Learning-6th Week jobs

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.