The I and small partners to share a Linux system command directory and file management used, then I will carry out a detailed analysis from the following points and everyone
- Linux Directory Structure
- View and retrieve files
- Backup and recovery documentation (compressed format)
- VI text editor
(A) .Linux directory structure
1. The directory tree structure
2. root directory:
all partitions, directories, files and other locations starting point
entire directory tree structure, the use of a separate "/" indicates
3. Common subdirectories:
/ root (system administrator home directory)
² / bin (executable for all users command)
² / the boot (system kernel, boot files)
² / dev (device file)
² / etc (profile)
² / home (general user home directory)
/ var (system log file)
² / usr (application)
² / sbin (administrator can perform administration commands)
² / opt, / mnt (empty file)
² / proc (hardware configuration information)
² / tmp ( temporary files, empty the restart)
² / lib, / lib64 (library system)(B). View and retrieve files
See cat command file contents:
cat command:
1. Purpose: To display the contents of a file points: cat [Option]
drawbacks: If the contents of the read file is too large, the line can not carry much, character interface terminal processes simultaneously, only You can see the contents of the end
Look at the file more command:
more commands:
1. Purpose: a full-screen page display file contents: more {filename} option
2. interworking method:
Press Enter to scroll down line by line
Press the spacebar to turn down one page press b upturned an
press q to exit
drawback: you can not determine the position of the last page, it is easy to exit, can not look back
See less command file content:
less commands:
1. Use: the same command more, but more extensions: less {filename} option
2. interworking method:
² Page Up Page Up, Page Down Page Down
² press the "/" Find what, "n" the next content, "N" a content
other functions substantially similar to the more command
View the contents of the file head, tail command:
1.head command:
Uses: View of part of the beginning of the file (the default is 10 lines): head -n filename
2.tail command:
Uses: View of a small part of the end of the file (the default is 10 lines :): tail -n filename or tail -f filename
Statistical wc command file contents:
1. Usage: The number of words in the file statistics (Word Count) and other information: wc [options] target file
2. Common command options:
² the -l: Statistics rows
-w: count the number of words
-c: count the number of bytes
File content retrieval and filtering grep command:
grep command:
1. Purpose: to locate and display lines containing a specified string in the file: {options} grep target file search condition
2. Common command options:
² -i: Ignore size when viewing write
-v: reverse lookup
3. Find the conditions set:
a string 're looking to double quotes
"^ ......" represented the beginning ...... indicate the end ...... "...... $."
"^ $ "represents a blank line
features: You can not operate import and export a file
Extra added:
"#" (comment):
description information, does not have the function
">" (redirection symbol):
encountered the same file will overwrite the contents directly, and does not ask
features: not fixed use, as long as the what screen terminal display, after which it will import the capture to a file and display the contents of
">>" (additional sign):
² does not change the contents of the source file, but will be directly added to the inside, do not ask
"|" (pipe symbol):
operation result to the front of the rear continue
. (Iii) backup and recovery documentation:
Compression command gzip, bzip2 command
gzip, bzip2 command
1. Purpose: production of the compressed file, the compressed file unlock:
² the gzip [-9] filename
bzip2 [-9] filename
gzip -d .gz compressed file format
² bzip -d .bz2 compressed file format
2. common command options: 9 (create), - d (decompression)
Conclusion: the source file to create compressed files disappear; after decompression, compression bag disappeared
Archive command tar command:
tar command:
1. Purpose: Create archive file, release archive:
tar [option] ... archive file name of the source file or directory
tar [option] ... the archive file name [-C target Catalog]
2. common command options:
² -c: create archive
-x: extract the
-v: show Details
-f: execution
-p: preserving permits
-t: View archive content
- C: extract the target path
-z: gzip format
-j: bzip2 format
(D) .VI text editor:
Text editor, vi command:
the role of the text editor:
- Create or modify file books
- Maintaining Linux systems in a variety of configuration files
- Linux is the most commonly used text editor:
² vi: UNIX-like operating copper default text editor
vim: vim is an enhanced version of vi text editor (generally referred to as the vi editor) of
Operating modes vi editor:
- Three operating modes: command mode, input mode, and last line mode
- Switching between different modes: [root @ localhost ~] #vi file name
in the command mode, we can input a, i, o button, etc., into the input mode, and the last line jump inserted state, the cursor can now be staying at different locations to edit it to add content, can be input is complete press the Esc key to return to command mode; Similarly, we can also be entered in command mode: enter the last line mode, if you want to return to the same command mode also press the Esc key, the following I conducted for different meaning in different keys represent explained:
² a: be inserted after the cursor position
i: be inserted before the cursor position
o: insert the next row position of the cursor
O: cursor row location of the insertion
M: cursor jumps to the screen middle row
Cursor:
1. direction:
² ↑, ↓, ←, →: upper, lower, left and right
2. page:
² Page Down or Ctrl + F.: A full page flipping down
Page Up or Ctrl + B: a full page flipping up
quickly jump the line 3:
² Home key or "^", the number "0": jump to the beginning of the line
End key or "$" key: jump to end of line
4. line Quick jump between:
² 1G or gg: jump to the first line of the file
G: Jump to the end of the line in the file
#G: jump to the first file line #
line numbers:
²: the SET NU: in editor display line numbers
: set nonu: cancel line numbers in the editor display
Copy, Paste, Delete:
1. Delete:
² Del or X: delete a single character at the cursor position
dd: delete the current cursor line
#dd: deleted starting from the cursor line # SUMMARY
d ^: delete the current cursor before to the beginning of all the characters
d $: delete the current cursor position to the end of the line all the characters
dw: delete the word
2. copy:
² YY: copy the entire contents of the current line to the clipboard
#yy: copied from the cursor line beginning with row #
3. paste:
² P: the contents of the buffer after pasted to the cursor position
before pasting the cursor position: P ²
² DDP: two rows swap
Find the file contents:
² / Word: Find a string from the top down "word" in the file
word:? Find in Files and on the string "word" from
n: Character locate the next match being sought string
N: positioning the search string matching
Undo edit and save out:
² u: Press once to cancel a recent operation; repeat u key, to recover the multi-step operation
U: for the removal of all edits made to the current row
ZZ: saves the current contents of the file and exit vi editor
Shift + 2: replace the corresponding character
Save the file and exit the vi editor:
1. Save the file:
²: w: save the modified content
: w / root / newfile: save as another file
2. Quit vi:
²: q: quit unmodified
: q !: abandon contents of the file and exit vi
Open a new file or other file read content:
²: E ~ / the install.log: open a new file for editing
: r / etc / filesystems: reading the contents of other files in the current file
Replace File Content:
²: S / Old / new new: the current line to find the first character "old" is the string for the "new new"
²: S / Old / new new / G: the current line to find all character "old" is the string for the "new new"
²: replace all strings "old" the row number "#," the range of "new new": #, # S / Old / new new / G
²:% S / old / new / g: replace all the strings "old" range in the entire file "new new"
²: / Old / new new / c: c is added in the alternative end of the command command, each replacement operation will prompt the user for confirmation