First, the file system
1. Introduction to Linux File system:
The Linux file system is a hierarchical tree-like structure with the root directory "/" at the top of the directory structure, and the rest of the directories are created in this directory.
2. Linux part of the most common important directory:
/: Upper-level root directory of Linux file system
/root: Host directory for Superuser Root
/home: Host directory for ordinary users, each user has a directory with the same name as the user name in the directory
/bin: A directory that holds commonly used commands, an executable command for ordinary users, and any user of the system can execute commands in that directory
/sbin: System Management commands, normal users can not perform
/MNT: The default hanging in the CD-ROM and floppy drive directory, you can not hang here
/boot: Save boot-related files, files required for system startup
/ETC: Storing System configuration Files
/var: Store frequently changing files, such as log files and user mail
/usr: default installation path for software
/tmp: Temporary directory of the system
Second, the file Operation command
1. View current directory
Pwd
2. Directory Jump
Cd
Example: Jump to/home/pds Directory
Cd/home/pds
Return to Parent Directory
Cd..
Go to the subordinate subdirectory of the current directory
CD Home
3. listing files and directories
Displays only the file name and directory name under the directory: LS
Displays the file name and directory name under the directory, including hidden files: ls-a
Displays the details of the file name and directory name under the directory (L is lowercase l): ls-l
Pagination Displays query Results (| is the pipe command, SHIFT + \): ls-l | More
Description: The pipeline command is to give the result of the previous command to | The following command
4. Create an empty directory
Mkdir
Example: Create an empty directory folder Pds:mkdir PDS
5. Delete Empty directory
RmDir
Example: Deleting an empty directory folder Pds:mkdir PDS
6. Create an empty file
Touch
Example: Creating an empty file Emptyfile
Touch Emptyfile
7. Copy Directory
Cp-r Source Directory target Directory
For example: Copy all files and folders under the/root/pds directory and directory to/root/andgoo
Cp-r/root/pds/root/andgoo
The directory structure after replication is:/root/andgoo/pds ...
8. Copy files
CP source file absolute path target directory
Example: Cp/root/pds/emptyfile/root/andgoo
9. Delete Files
RM File Absolute Path
Example: deleting emptyfile files: rm/root/andgoo/emptyfile
Prompt for deletion, enter Y, and then return
10. Delete all contents under current directory, excluding the current directory itself
RM-RF *
Command explanation: R recursion; f coercion
11. Modify File Name
MV Original filename modified file name
Example: Modify the Emptyfile file to MVFILE:MV emptyfile mvfile
12. Moving Files
MV Target file target path
For example: Move em files to the/root directory: MV em/root/
13. Mobile directory and Directory of files
MV Source Directory target directory
Example: Move the contents of the/root/pds directory and directory to the/root/andgoo: Mv/root/pds/root/andgoo
After moving the target directory structure is:/root/andgoo/pds ...
There are no more/PDS directories in the/root directory
14. Establish a connection
Ln-s source file path connection name
Example: Establish a connection for the/etc/inittab file with the connection named Inittab:ln-s/etc/inittab inittab
Description: Use command ls-l to see the source file that the connection file points to
15. Find text content
grep "What to find" destination file path
Example: 1. Find out if HelloWorld characters appear in the/root/test.java file: grep "HelloWorld"/root/test.java
2. Find out if HelloWorld characters appear in multiple files (separated by spaces between the target files): grep "HelloWorld"/root/test.java/root/pds/testjava.java
3. Find results returns the number of rows (plus-N): Grep-n "HelloWorld"/root/test.java
16. target File Search
A. Searching by name: Find search directory-name target filename
Example: Find a file named Test in the/root directory: Find/root-name Test
B. Find files or directories that have been accessed/modified over a period of time:
Example: 1. /home directory, files or directories read in 10 minutes: find/home-amin-10
2. Files or directories that have been read within 10 hours in the/home directory: find/home-atime-10
3. Files or directories modified in 10 minutes under the/home directory: find/home-cmin-10
4./home directory, 10 hours before the modified file or directory: Find/home +ctime-10
Description: A for access; C for change;+;
C. Find by Size
Example: Find files larger than 10k in the/home directory: Find/home-size +10k
Description: + is greater than;-is less than
Cat command
The Cat command has three main features:
1. Display the entire file without paging.
Cat file name
2. Create a file from the keyboard that can only be created and cannot be edited.
Cat > FileName
3. Merging several files into one file.
Cat source files 1 source files 2 > Target files
Parameter description:
-N: Number of rows for all outputs (numbering starting from 1)
-B: Similar to-N, except for blank lines not numbered
-S: A blank row with two consecutive lines is encountered and replaced with a line of blank lines
Cases:
A. Insert the contents of document 1 with the line number and write to document 2: Cat-n file 1 > file 2
B. Append the contents of document 1 and document 2 to the end of file 3 after adding the line number (blank line not added). Cat-b file 1 File 2 >> file 3
C. Empty/etc/test.txt file content: cat/dev/null >/etc/test.txt
The content of this site is used here: http://www.9usb.net/200902/linux-cat.html
18. Enter REDIRECT Command
Overwrite:>
Append:>>
Example: A. Writes the contents of the current directory to the A.txt file as overridden: ls-l > A.txt
B. Write the contents of the current directory to the A.txt file appended to the end of the file: ls-l > A.txt
19. Output redirection
<
Example: Output redirection a more common side: Cat < A.txt
NOTE: command usage hint: Man command
Exit Man:q