Note:
1. If the number is an odd number, 9th questions will be asked. If the number is an even number, 8th questions will be asked;
2. The variable names start with their first-letter abbreviations;
1. Write a script:
1) if it does not exist, create a directory/backup;
2) backup/etc directory to/backup, and add a date suffix after the original name, such as: etc-2011-07-29;
3) set the script to automatically run at 03:10 every week on Thursday and Sunday;
2. Write a script:
1. Create a directory/tmp/test
2. Switch the working directory to this directory.
3. Copy the/etc/PAM. d directory to the current directory and run the command Pam again.
4. Change Pam in the current directory and its file and subdirectory owner to RedHat.
5. Change the permissions of other users of files in the test and its subdirectories to No permissions.
6. Use functions to implement the above functions;
3. Write a script:
1) obtain the network address of the Local Machine. For example, if the IP address of the local machine is 192.168.100.2/255.255.255.0, the network address of the local machine is 192.168.100.1/255.255.255.0.
2) obtain the local gateway. If no gateway exists, it is displayed as none;
3) obtain the DNS server address of the Local Machine. None is displayed if no DNS server address exists;
4. Write a script:
The content of a file is as follows:
Jack f 90
Tom M 70
Jerry F 99
Lily m 80
Where F is female and M is male. Calculate the average age of male and female;
5. Write a script:
1) implement with functions:
Determine whether a user exists and pass the user name through parameters;
If the user exists, the user's shell and uid are displayed.
If the user does not exist, the user does not exist;
2) in the main function, the user is always prompted to enter the user name and displayed until the user enters Q or Q to exit;
6. Write a script to set a static address for the NIC:
1) The system prompts you to select the network card you want to set;
2) The user is prompted to enter the IP address, subnet mask, and gateway. The Gateway can be blank, but the IP address or subnet mask cannot be blank. After the settings are complete, restart the NIC;
3) If you press Ctrl + C during the process, you must be able to capture the signal and cancel the previous operation;
7. Write a script to meet the following requirements:
The content of a text file is as follows:
User1 ABCD
User2 g23d
User3 vgq2
Create users in batches Based on the file content. The first column is the user name and the second column is the password of the corresponding user. Requirements:
Use functions to add users. Before adding a user, you must determine whether the user exists;
8. Write a script:
1. download the file ftp: // 192.168.0.254/pub/files/access_log to the/tmp directory;
2. Analyze and display the top five IP addresses at the beginning of the line in the/tmp/access_log file that appear the most frequently, and describe how many times each IP address appears;
3, take out the/tmp/access_log file with http: //, followed by a domain name or IP address string, such as: http://www.linux.com/install/images/style.css of the http://www.linux.com of this string; the first five most frequently displayed items are displayed;
Requirements: 2nd and 3 functions are implemented in the form of functions;
9. Write a script:
1. Define a function
1) The MEM, swap, or disk parameters are acceptable;
2) When the mem parameter is accepted, the size of the physical memory of the current host, used space, and idle space are obtained. If the used space exceeds 90% of the total space, a red warning is given; otherwise, the percentage of remaining space is displayed in green;
3) when SWAp is accepted, obtain the virtual memory size, used space, and idle space of the current host. If the used space exceeds 90% of the total space, a red warning is given; otherwise, the percentage of remaining space is displayed in green;
#4) when the swap parameter is accepted, obtain the size of the current host/dev/SDA disk as the partition, used space and idle space. If the used space exceeds 90% of the total space, the warning is in red. Otherwise, the percentage of remaining space is displayed in green;
3. A prompt is displayed in the main program, indicating that the input mem can display the usage of the physical memory space; the input swap can display the usage of the virtual memory space; any other characters prompt the user to use the script and exit the script;
2. Write a script to manually add a user:
1) prompt the user to enter the user name;
2) append a row to the/etc/group file according to the format and create a group with the same name as the user. The ID number must not be the same as the existing group;
3) append a line to the/etc/passwd file according to the format to create this new user. The ID number must not be the same as the existing user;
4) append a row to the/etc/shadow file according to the format;
5) Add a password for this user;
6) to create a home directory for this user, the permission and owner group must be properly set and the corresponding environment configuration file must be available;