Chapter Fourth catalogue and document management (II)

Source: Internet
Author: User
Tags gz file

Chapter Fourth catalogue and document management (II)

Enjoy Life and love the challenge

Mingyuan Share

A paragraph of each chapter:

No matter what you do, you have to go ahead: No matter how hard it is, you have to hold on a bit more. Never underestimate your ability to realize your dreams.

Requirements:

Ø practice file viewing and retrieval operations

1. Check the/etc/filesystems file to confirm the file system type supported by the current system

Cat command-Displays and connects (concatenate) the contents of the file 650) this.width=650; "Style=" border-right-0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px "border=" 0 "alt=" wps7070.tmp "src=" http://s3.51cto.com/wyfs02/M01/58/73/ Wkiom1swqauwmiboaaavperlizo402.jpg "width=" 244 "height=" "/>

2. Paging through the/etc/services file to see the protocols, port numbers used by default for various services

More and less commands-paging to view file contents 650) this.width=650; "Style=" border-right-0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px "border=" 0 "alt=" wps7080.tmp "src=" http://s3.51cto.com/wyfs02/M02/58/70/ Wkiol1swqnpiw5fiaabniv8esp0020.jpg "width=" 244 "height=" 137 "/>

3, filter out the physical memory size, free memory size from the/proc/meminfo file

grep command-Retrieve, filter file contents

Basic usage Format:

grep [Options] ... Find a conditional target file

-I: Ignore capitalization when finding content (Lgnore case)

-V: Reverse lookup (InVert), which outputs rows that do not match the lookup criteria. 650) this.width=650; "Style=" border-right-0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px "border=" 0 "alt=" wps7081.tmp "src=" http://s3.51cto.com/wyfs02/M00/58/70/ Wkiol1swqnozxctmaaasy8vpnoo041.jpg "width=" 244 "height="/>

4,WC command-Information about the number of German words (word Count), number of lines, etc. in the statistics file contents

-C: Statistics the number of bytes in the file contents

-L: Statistics the number of rows in the file contents

-W: The number of words in the statistics file (separated by a space or tab) 650) this.width=650; "Style=" border-right-0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px "border=" 0 "alt=" wps7082.tmp "src=" http://s3.51cto.com/wyfs02/M00/58/73/ Wkiom1swqa-b9rpoaaapcjdhtlg460.jpg "width=" 244 "height=" "/>650" this.width=650; "style=" border-right-0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px "border=" 0 "alt=" wps7083.tmp "src=" Http://s3.51cto.com/wyfs02/M01/58/74/wKiom1Swqa_ Bkoo5aaapzaarzsa883.jpg "width=" 244 "height=" "/>650" this.width=650; "style=" border-right-0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px "border=" 0 "alt=" wps7094.tmp "src=" Http://s3.51cto.com/wyfs02/M02/58/74/wKiom1Swqa_ I0vujaaapnayboss796.jpg "width=" 244 "height="/>

Ø practice Backup and recovery operations

Tar command-archive and release tools (both to compress files and to compress directories)

-c: Create. tar format package file

-C: Specify the target folder to release when unpacking

-F: Indicates the use of an archive file

-j: Call the BZIP2 program for compression or decompression.

-P: Preserve file and directory permissions while packaging

-P: Preserve the absolute path of files and directories while packaging

-T: List view files in package

-V: Output details (Verbose)

-X: Unpack package files in. tar format

-Z: Call the gzip program for compression or decompression

1, backup the whole/etc directory tree, made into archive compressed package file etc.tar.gz650) this.width=650; "Style=" border-right-0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px "border=" 0 "alt=" wps7095.tmp "src=" http://s3.51cto.com/wyfs02/M00/58/74/ Wkiom1swqbdc6w8iaaarutqtvuo366.jpg "width=" 244 "height="/>

2. View the list of directories and files contained in the etc.tar.gz file

Input command: Tar ZTVF etc.tar.gz

650) this.width=650; "Style=" border-right-0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px "border=" 0 "alt=" wps7096.tmp "src=" http://s3.51cto.com/wyfs02/M01/58/74/ Wkiom1swqblxzjfoaacbns-x7ky961.jpg "width=" 244 "height=" 137 "/>

4, restore the etc.tar.gz file to the/tmp directory, confirm and then delete the/tmp/etc folder

650) this.width=650; "Style=" border-right-0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px "border=" 0 "alt=" wps7097.tmp "src=" http://s3.51cto.com/wyfs02/M02/58/74/ Wkiom1swqboxe3noaaau_jgydl4826.jpg "width=" 244 "height=" "/>650" this.width=650; "style=" border-right-0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px "border=" 0 "alt=" wps70a8.tmp "src=" http://s3.51cto.com/wyfs02/M00/58/74/ Wkiom1swqbthgzrxaaan9yk4poy973.jpg "width=" 244 "height="/>

5, Gzip and Gunzip commands-compression and decompression tools (only files can be compressed)

Compression:

650) this.width=650; "Style=" border-right-0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px "border=" 0 "alt=" wps70a9.tmp "src=" http://s3.51cto.com/wyfs02/M01/58/74/ Wkiom1swqbjqpndzaaacbbmk7o4777.jpg "width=" 244 "height="/>

Unzip:

650) this.width=650; "Style=" border-right-0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px "border=" 0 "alt=" wps70aa.tmp "src=" http://s3.51cto.com/wyfs02/M02/58/74/ Wkiom1swqbjrjmqxaaan7ooiifu103.jpg "width=" 244 "height="/>

Or

650) this.width=650; "Style=" border-right-0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px "border=" 0 "alt=" wps70ab.tmp "src=" http://s3.51cto.com/wyfs02/M00/58/74/ Wkiom1swqbiapeieaaal2vtxune442.jpg "width=" 244 "height="/>

6, bzip2 and BUNZIP2 commands-compression and decompression tools (only files can be compressed)

Compression:

650) this.width=650; "Style=" border-right-0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px "border=" 0 "alt=" wps70ac.tmp "src=" http://s3.51cto.com/wyfs02/M00/58/70/ Wkiol1swqn6to70taaadbvcdyao897.jpg "width=" 244 "height=" Notoginseng "/>

Unzip:

650) this.width=650; "Style=" border-right-0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px "border=" 0 "alt=" wps70ad.tmp "src=" http://s3.51cto.com/wyfs02/M01/58/74/ Wkiom1swqbycjzfvaaaold00bqm789.jpg "width=" 244 "height="/>

Or

650) this.width=650; "Style=" border-right-0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px "border=" 0 "alt=" wps70ae.tmp "src=" http://s3.51cto.com/wyfs02/M02/58/74/wKiom1Swqb_ Aiavbaaamiypla3m987.jpg "width=" 244 "height="/>

Ø Practice VI Editor's basic use

1, through "Man Man | Col-b > Man.txt "action to create a Text Man command page, edit with VI

Open a. man.txt file as a material for practice

650) this.width=650; "Style=" border-right-0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px "border=" 0 "alt=" wps70be.tmp "src=" http://s3.51cto.com/wyfs02/M00/58/74/ Wkiom1swqb-cq3-saaapnxkiwau446.jpg "width=" 244 "height="/>

2, switch to the last line mode, and enter the ": Set nu" command to display the travel number

Step: Press the "ESC" key first, then enter the colon ":" To switch to the last line mode, and then enter the command "Set Nu", press ENTER. :

650) this.width=650; "Style=" border-right-0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px "border=" 0 "alt=" wps70bf.tmp "src=" http://s3.51cto.com/wyfs02/M01/58/74/ Wkiom1swqchttcqkaabusjazrxw485.jpg "width=" 244 "height=" 137 "/>

3, copy the inner space of line 6th to line 2nd, and delete several blank lines after line 2nd

Steps:

1. First press "ESC" key, switch to command mode, then move the cursor to line 6th, press two lowercase "y" key, then move the cursor to line 2nd, press the "P" key in uppercase. :

650) this.width=650; "Style=" border-right-0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px "border=" 0 "alt=" wps70d0.tmp "src=" http://s3.51cto.com/wyfs02/M02/58/74/ Wkiom1swqckye9bwaabyuvl1y6c716.jpg "width=" 244 "height=" 137 "/>

Copy operation: Use the key command yy to copy the contents of the entire row of the current line to the Clipboard, using the form of #yy can also copy the # line from the cursor at the beginning of the content (where "#" is replaced by a specific number). The copied content needs to be pasted before it can be used.

Paste operation: In the VI editor, the previous deleted or copied content will be saved to the Clipboard buffer, press the P key to paste the contents of the buffer at the cursor position, press the P key will be pasted at the cursor position before.

2. Then move the cursor to line 3rd, then quickly press the number "3" key and two lower case "D" key to delete the empty line. :

650) this.width=650; "Style=" border-right-0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px "border=" 0 "alt=" wps70d1.tmp "src=" http://s3.51cto.com/wyfs02/M00/58/74/ Wkiom1swqcswntoiaabyimlf-3g312.jpg "width=" 244 "height=" 137 "/>

Delete operation:

u use the X or del keys to delete a single character at the cursor

u use the key command DD to delete the current cursor line, using the form of #dd can also be deleted from the beginning of the cursor # line content (where "#" is replaced by a specific number)

u use key command dˆ to delete all characters before the current cursor to the beginning of the line

u use key command d$ to delete all characters at the end of the line at the current cursor

4, find the "-K" string in the file

Step: In the last line mode, press the "/" key to enter the specified string, from the current cursor to start the backward search (if you press "? "Key is searched forward.) After you finish the lookup, you can press the N key to look backwards, and the N key to look forward. :

650) this.width=650; "Style=" border-right-0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px "border=" 0 "alt=" wps70e1.tmp "src=" http://s3.51cto.com/wyfs02/M01/58/74/ Wkiom1swqcba-oghaabs_gw3v24222.jpg "width=" 244 "height=" 137 "/>

5. Replace All "string" strings in the file with "Benet"

Steps:

Last-line command format when using the Replace function:

: [Replace Range] Sub/old content/new content [/g]

ø%: Find and replace throughout the file content

650) this.width=650; "Style=" border-right-0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px "border=" 0 "alt=" wps70e2.tmp "src=" http://s3.51cto.com/wyfs02/M02/58/74/ Wkiom1swqcmgnz0waabxqukj01e649.jpg "width=" 244 "height=" 137 "/>

Øn,m: Find in file contents within a specified number of lines

For example, to replace the "Initdefault" string in the 第5-15 line in a document with "DEFAULT", you can do the following:

: 5,15 sub/initdefault/default/g

Ø the "/g" section at the very end is also optional, indicating that all matching results for each row in the replacement range are replaced, and omitting "/g" will replace only the first matching result in each row.

6. Exit the VI Editor after saving the file

Steps:

Switch to the last line mode, then enter the "Wq" key, then press ENTER to save and exit. :

650) this.width=650; "Style=" border-right-0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px "border=" 0 "alt=" wps70f3.tmp "src=" http://s3.51cto.com/wyfs02/M00/58/74/ Wkiom1swqcrbykpgaabeveyk9k0361.jpg "width=" 244 "height=" 137 "/>

Undo Edit and Save and exit:

When editing the contents of the file, sometimes you will need to undo some of the errors of editing operations, you can use the key command u, u key. The U-key command is used to cancel the most recent operation, and to reply to the result of the operation, you can repeatedly press the U key to recover a multi-step operation; the U-key command cancels all edits made to the current line. You can press the ZZ command when you need to save the current file contents and exit the VI editor.

To save the file and exit the VI editor:

Ø save file: After modifying and confirming the contents of the file, the ": w" command needs to be saved.

If you need to save as a different file, you will need to specify a new file name and, if necessary, specify a path to the file. For example, performing a ": W/root/newfile" operation will save the currently edited file to the/root directory with the file name NewFile.

Ø Exit Editor: When you need to exit the VI editor, you can execute the ": Q" command. If the contents of the file have been modified but not saved, use only ": Q" command will not successfully exit, you need to use ": q!" Command forced exit (exit without saving)

Ø Save and exit: Both save the file and exit the VI Editor can be implemented using an end-of-line command ": Wq" or ": X". The effect is the same as the ZZ command in command mode.

7, reopen the Man.txt file, keep only the first 5 rows, delete all the rest of the content

Steps:

Switch to command mode, move the cursor to line 6th, and then quickly press the number key "1000" and two lower case "D" keys. :

650) this.width=650; "Style=" border-right-0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px "border=" 0 "alt=" wps70f4.tmp "src=" http://s3.51cto.com/wyfs02/M00/58/74/ Wkiom1swqcudfsusaaaqcplwljo606.jpg "width=" 244 "height=" 137 "/>

8. Copy the contents of the/ROOT/.BASHRC file to the 5th line, then save as Man2.txt file

Steps:

1. Switch to the last line mode, then enter ": R/ROOT/.BASHRC" and press ENTER. :

650) this.width=650; "Style=" border-right-0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px "border=" 0 "alt=" wps70f5.tmp "src=" http://s3.51cto.com/wyfs02/M02/58/70/ Wkiol1swqpgrl5j-aaaqywmyjbg926.jpg "width=" 244 "height=" 137 "/>

2. Then enter the command ": w man2.txt" in the last-line mode and press ENTER. :

650) this.width=650; "Style=" border-right-0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px "border=" 0 "alt=" wps7106.tmp "src=" http://s3.51cto.com/wyfs02/M00/58/70/ Wkiol1swqpkagrukaabaqjgskdw083.jpg "width=" 244 "height=" 137 "/>

Open a new file or read the contents of another file:

U open a new file for editing: in the current VI editor, execute ": E new File" in the form of the last line command can edit (edit) the new file.

U reads other file contents in the current file: The last line in the form of ": R other File" can read the contents of (read) other files and copy them to the current cursor location.

Ø Modify system configuration using VI

1, backup the/etc/inittab,/etc/issue files so that they can be restored if necessary

Steps:

650) this.width=650; "Style=" border-right-0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px "border=" 0 "alt=" wps7107.tmp "src=" http://s3.51cto.com/wyfs02/M01/58/70/ Wkiol1swqppimwaxaaavtpjxyay797.jpg "width=" 244 "height="/>

2, open the/etc/inittab file with the VI editor to find the string containing "Id:5:initdefault:"

Line, modify it to "Id:3:initdefault:"

Steps:

1. Find the string containing "Id:5:initdefault:" and enter ":/id:5:initdefault:". :

650) this.width=650; "Style=" border-right-0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px "border=" 0 "alt=" wps7117.tmp "src=" http://s3.51cto.com/wyfs02/M01/58/74/ Wkiom1swqdlaubcqaabfq6paos0432.jpg "width=" 244 "height=" 137 "/>

2. Then press the lowercase key "a" to switch to input mode and change "Id:5:initdefault:" to "Id:3:initdefault:". :

650) this.width=650; "Style=" border-right-0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px "border=" 0 "alt=" wps7118.tmp "src=" http://s3.51cto.com/wyfs02/M02/58/74/ Wkiom1swqdttjr4raabhkre64rs095.jpg "width=" 244 "height=" 137 "/>

3, open the/etc/issue file with VI Editor, delete all the contents, add a new line of text

"Windows Server Enterprise RC2" (or other text written by the user himself)

Steps:

650) this.width=650; "Style=" border-right-0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px "border=" 0 "alt=" wps7129.tmp "src=" http://s3.51cto.com/wyfs02/M00/58/74/ Wkiom1swqdnxirxvaaatgdcmuie891.jpg "width=" 244 "height=" 137 "/>

4, restart the system to observe the changes in the Linux login interface (text interface, personalized login prompt)

Steps:

650) this.width=650; "Style=" border-right-0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px "border=" 0 "alt=" wps712a.tmp "src=" http://s3.51cto.com/wyfs02/M01/58/74/ Wkiom1swqewcspraaaalweicjyi639.jpg "width=" 244 "height="/>

5, restore the contents of/ETC/INITTBA,/etc/issue files according to backup files

Steps:

650) this.width=650; "Style=" border-right-0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px "border=" 0 "alt=" wps712b.tmp "src=" http://s3.51cto.com/wyfs02/M02/58/71/ Wkiol1swqrxryoqjaaayqbv4bqc589.jpg "width=" 244 "height="/>

Note: If you want to back up the restore, do not appear when the backup path, it is necessary to enter the directory, and then back up the contents of the directory.

Chapter Fourth catalogue and document management (II)

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.