Old boy Linux Ops first quiz

Source: Internet
Author: User
Tags parent directory

1.1 I want to create a oldboy.txt file under the/data/oldboyedu directory
[[Email protected]~]# cd/data/oldboyedu-bash:cd:/data/oldboyedu:no such file or directory

1. Why this error has occurred

Answer: No/data directory or no/data/oldboyedu/directory

2. How do I resolve this error?

[[Email protected]~]# mkdir-p/data/oldboyedu[[email protected]~]# cd/data/oldboyedu[[email protected]]# Touch Oldboy.txt
1.2 Add the content "I love Studyinglinux" to Oldboy.txt. (not less than 2 methods)
French one: [email protected]]# echo ' I love studying Linux. ' >oldboy.txt[[email protected]]# cat Oldboy.txti lovestudying Linu X. Law II: [[email protected]]# cat >oldboy.txti lovestudying linux.^c[[email protected]]# cat Oldboy.txti lovestudying Linux. Law III: [[email protected]]# vi oldboy.txt--a/i--esc--:wq: [Email protected]~]# cat >>oldboy.txt<<eof > I lovestudying linux.> EOF
1.3 Copy the/data directory to the/tmp directory
[Email protected]]# cp-r/data/tmp/[[email protected]]# ls/tmp9.txt b.txt data yum.log z.txt[[email protected]]# CP -a/data/tmp/cp:overwrite '/tmp/data/oldboyedu/oldboy.txt '? Y[[email protected]]# ls/tmp/9.txt b.txt data yum.log z.txt
1.4 Say these special symbolic meanings: >> > 2> 2>> # (pound). (point): (two points)
>>:1>>, append standard output redirect, do not erase content, add content to last line, >:1> standard output redirect, erase old content, add new content; 2>: Error output redirect; 2>>: error append output redirect; #:1) Note; 2) represents the root user;.:./, current directory;. :.. /, the parent directory of the current directory;


1.5 Test.txt content is:
Trainningfanbingbinglidao

Create an environment: law one:[[email protected]]# cat >>test.txt<<eof>training>fanbingbing>  lidao> eof method Two:[[email protected]]# echo  "Trainingfanbingbinglidao" >test.txt[[ Email protected]]# cat test.txttrainingfanbingbinglidao does not contain a trainning string of command law one:[[email  protected]]# sed -n  ' 2,3p '  test.txtfanbingbinglidao Law II: [[Email protected]]# head  -3 test.txt|tail -2fanbingbinglidao Law Three:[[email protected]]# tail -3  Test.txt|grep -v trainingfanbingbinglidao method Four:[[email protected]]# grep -v  ' Training '  test.txtfanbingbinglidao Law v:[[email protected]]# awk  ' nr==2,nr==3 '   test.txtfanbingbinglidao[[email protected]]# awk  ' {if (nr>=2&&nr<=3) print $0 " \ n "} ' Test.txtfanbingbing lidao six:[[email protected]~]# awk  ' {if (nr==2| | nr==3)  print $0 "\ n"} '  test.txtfanbingbing liDAO Note: [[Email protected] ~]# awk ' {if (nr>=2| | nr<=3)  print $0 "\ n"} '  test.txttraining fanbingbing lidao
1.6 New company, boss let you restrict the RM command on the server, when the user enters the RM command Prompt "RM command is not allowed touse." What are the steps to achieve this?
Temporary modification: [[email protected]~]# alias rm= ' Echo ' Alias RM=RM command is not allowed to use "' [[email protected]~]# alias Rmaliasr M= ' echo ' Alias RM=RM command is isn't allowed to use "' [[email protected]~]# rm-f 1.txtalias Rm=rmcommand ' isn't allowed to Use-f 1.txt Permanent: 1) alias rm= ' echo RM command is not allowed-use ' (Temporary entry into force) 2) writes the contents of 1) to the last line of the/etc/profile file by using vim 3) source/etc /profile command makes the file permanent 4) go to/ROOT/.BASHRC under alias rm= ' rm-i ' comment out that # ' Alias rm= ' Rm-i '
1.7 Remove the contents of the 30th to 40th line of the file ett.txt.

Note: Ett.txt created by seq >ett.txt

Create a simulated environment: [[email protected]~]# seq] >ett.txt: [[email protected]~]# head-40 ett.txt|tail-11 Law II: tail-72ett.txt|h EAD-11 Law III: sed-n ' 30,40p ' Ett.txt Law IV: awk ' nr==30,nr==40 ' Ett.txtawk ' nr>=30&&nr<=40 ' ett.txt Law V: awk ' {if (NR >=30&&nr<=40) print "\ n"} ' Ett.txt Note: (not taken out) [[email protected] ~]# awk ' {if (nr==30| | NR==40) print $ "\ n"} ' ett.txt49 59
1.8 Modify the trainning in the Test.txt file to Oldboy.
Law one: [email protected]~]# sed-i ' s#training#oldboy#g ' Test.txt[[email protected]~]# cat Test.txtoldboyfanbingbinglidao Law II: Vi/vim test.txt--A/I--INSERT--ESC--:WQ
1.9 Find all files in the/data directory ending in. txt, and modify the trainning in the file to Oldboy.
[Email protected]~]# find/data/-type f-name "*.txt" |xargs sed-i ' s#training#oldboy#g ' [[Email protected]~]# find/data /-type F-name "*.txt"-exec sed-i ' s#training#oldboy#g ' {} \; [Email protected]~]# sed-i ' s#training#oldboy#g ' find/data/-type f-name ' *.txt ' [[email protected]~]# sed-i ' S#trai Ning#oldboy#g ' $ (find/data/-type f-name "*.txt")
1.10 Find/oldboy all 7 days ago the file that is greater than 1M, ending with log, is copied to/TMP.
Law one: find/oldboy/-type f-name "*.log"-mtime +7-size +1m |xargs-i cp {}/tmp/Method II: Find/oldboy-type f-name "*.txt"-mtim E+7-size +1m-exec cp {}/tmp/\ Three: CP ' Find/oldboy-type f-name "*.txt"-mtime +7-size+1m '/tmp/= = = Anti-Quote Method IV: CP $ (FIN  D/oldboy-type f-name "*.txt"-mtime+7-size +1m)/tmp/Law V: find/oldboy-type f-name "*.txt"-mtime+7-size +1M|xargs CP -t/tmp/
1.11 Please describe the difference between buffer and cache (additional question)?

A: Buffer: Write data to memory, the memory space to write data is called buffer, short buffer; cache: Read data from memory, the memory space to read the data is called buffer, short cache; Summary: Write buffer, read cache.


Old boy Linux Ops first quiz

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.