2017 the latest enterprise Shell face test and enterprise operation and maintenance of a total of 30 cases

Source: Internet
Author: User

1, enterprise Shell face question 1: Batch generate random character file name case

Use the For loop to bulk create 10 HTML files in the/oldboy directory, where each file needs to contain 10 random lowercase characters plus a fixed string oldboy, with the following name examples:

[Email protected] c19]# ls/oldboyapquvdpqbk_oldboy.html  mpyogpsmwj_oldboy.html  txynzwofgg_ oldboy.htmlbmqiwhfpgv_oldboy.html  mtrzobsprf_oldboy.html  vjxmlflawa_oldboy.htmljhjdcjnjxc_oldboy.html  qeztkkmewn_oldboy.htmljpvirsnjld_oldboy.html  ruscyxwxai_oldboy.html

Answer:

#!/bin/! -d/oldboy] && mkdir/oldboy-p for in {. Ten }do  pass1-'  /oldboy/${pass}_ Oldboy.htmldone

2, enterprise Shell face question 2: Batch renaming special cases

Change the Oldboy string in the result file name in the above interview title to Oldgirl (preferably with a for loop) and change the extension HTML all to uppercase

Answer:

Method One:
#!/bin/sh for in ' Ls/oldboy/*. html ' do mv $i ' echo $i |sed ' s#oldboy.html# Oldgirl. Html#g ' done
method Two:*.html
method Three:#!/bin//oldboy && for in ' ls ' do   str= ' echo $i |cut-c'  mv ${str}_oldboy.html ${str}_oldgril. Htmldone

3, Enterprise Shell face question 3: Batch Create special requirements user case

Batch Create 10 System account OLDBOY01-OLDBOY10 and set the password (password is random number, require characters and numbers and so on mixed)

Answer:

#!/bin/Bash forNinch{ on..Ten} DoPass= ' Uuidgen|cut-c1-Ten' ID oldboy$n&>/dev/NULL  if[$?-ne0];then useradd oldboy$n echo $pass|PASSWD--stdin oldboy$n &>/dev/NULLEcho-E"user:oldboy$n Pass: $pass">>/tmp/User.logElseEcho"Oldboy$n already exists"Fidone

4, Enterprise Shell face question 4: Scan Network Live host case

Write a shell script to determine what IP is currently online in the 10.0.0.0/24 network.

Answer:

#!/bin//etc/init.d/functions for in {1.. 254 } do10.0.     0. $ip &>/dev/null   if 0] then "      10.0.0. $ip" /bin/true  fidone

5, Enterprise Shell face question 5: Solve the Dos attack production case

Write a shell script to solve the DOS attack production case. Depending on the Web log or the number of network connections, monitoring when an IP concurrent connection number or a short time PV reaches 100 (readers according to the actual situation set), that is, call the firewall command to block the corresponding IP. The firewall command is: iptables-i input-s IP Address-j DROP

Answer:

2017 the latest enterprise Shell face test and enterprise operation and maintenance of a total of 30 cases

Related Article

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.