Related operations in the virtual machine files and directories

1.linux System Architecture

1) linux is a reciprocal structure

2) linux file all things are

3) These files are in the system top-level directory "/" is the root directory

4) / directory secondary directory, the system is automatically established when installed

2. The role of the secondary directory system

/ Bin # commonly used system commands

/ Sbin # system management commands

/ boot # boot partition
/ sys # kernel parameter adjustment
/ dev # device file

/ Lib # 32-bit library files

/ lib64 # 64 library file
/ media / run / mnt # temporary device mount point
/ opt # third-party software installation location
/ proc # System Information
/ etc # system configuration directory
/ home # ordinary user's home directory
/ root # superuser home directory
/ var, / srv # system data

3. Path

Absolute path: the real location of the file system can be used normally start with "/", such as / etc / passwd this directory anywhere on your system

Relative path: a short file name relative to the current system where the position, he usually automatically adds the value "pwd" before the name

4. File Management Commands

1) New file: touch file

 

 

 

 

 

 

2) new directory: mkdir test

 

 

 

3) delete a file or directory: rm -f filename; rm -fr directory name, -f expressed forcibly removed without prompting; -r recursive representation, that is to say, this will be inside the directory itself and its subdirectories and files together delete

 

 

 

Will enter the browsing mode vim file contents after the file name, then press the "i" key to enter insert mode after you can write the content, press "ESC" key to exit insert mode after the writing, then click ": 4) preparation of documents: wq "to save and exit on it (when writing use arrow keys to control the mouse position)

 

 

 

 

 

 

5) Check file contents: cat filename

 

 

 

If you want to add print line number it?

Use "cat -n filename"

If you do not want a blank line number, you can use "cat -b filename"

6) Copy the file: cp file name new file name | directory

 

 

 

 

 

 

 

Directory Replication: cp -r directory name new name | directory

 

 

 

 

 

7) move or rename: mv This command can also be used to move except for renaming operation

Format: mv file directory

mv Contents 1 Table of Contents 2

mv directory / *. ## "." is currently in the system directory

 

 

 

8) pwd #print work directory path to display the current location of the system where

 

 

 

9) to switch the working directory
cd directory name
cd .. ## into the current directory of the parent directory

## before entering the directory the current directory - cd

 

 

 

Show 10) files
ls

All files ls -a ##-point display, including hidden files that begin with

 

 

 

recursively ls -R ## show all contents of a directory

 

 

 

5. character match

File we want to copy multiple files, delete, or other operations, this time you need to use a character to match, can match you want to operate them operate

* 0 to ### matches any character

? ### matches a single character
[[: alpha:]] ### matches a single letter
[[: lower:]] ### matches a single lowercase letter
[[: upper:] ### matches a single uppercase letter
[[: digit :]] ### matches a single digital
[[: alnum:]] ### match a single number or letter
[[: punct:]] ### matches a single symbol

[[: Space:]] ### matches a single space

 

 

 

6. Regular Expressions

{1..9} ###1-9

{a..f} ###a-f
{1,3,5} ###135
{a,c,e} ###a c e

{1..3}{a..c} ###1a 2a 3a 2a 2b 2c 3a 3b 3c

[ ]

[the aC] aA bB cC ###
[AC] aA ### or bB or C
[1-3] ### 1, 2 or 3
[145] ### 1 or 4 or 5,

[^ Abc] | [! Abc] ### except that in addition to a and b and c except

 

 

 

{} And the difference between [] {} that define the character RE ranges are continuous, such as deleting all files file5 into file1 exists, but at least one or more file, can not be used if {rm -f file between 1 ..5}, use rm -f file [1-5], it will selectively match, to find the file file1 file5 present in the deletion, if the establishment of the file file1 file5 need to touch file {1..5 }, rather than touch file [1..5]

7.linux other commonly used text processing tool

1)

shows how much the line head ## before the specified file
head -n 1 passwd ## displays the first line of the file
before the line 5 head -n 5 passwd ## displays the file

head passwd ## 10 lines before the default file is displayed

 

 

 

2)

tail ## is displayed after the file number of the line
last line displays the file tail -n 1 passwd ## of
the last 5 lines tail -n display file 5 passwd ##

tail passwd ## displays the last 10 lines of a file

 

 

 

3) less ## tabbed browsing

less passwd

 

 

 

less can not only look back content can page forward, you can use the arrow keys to flip around

4) file ## file types View

Format: file file name

 

 

 

Like file.mp3 file.exe file and add the same content, display file type, the file type is determined by the content, rather than the file name

5)

wc ## word document statistics, the number of characters, number of bytes in
the number of wc -l ## rows
wc ## characters -m
WC -c number of bytes ##

wc -w ## words

 

 

 

Guess you like

Origin www.cnblogs.com/wufeng6/p/11899083.html