1. display file information ls list
-L long to View Details
-D. view directory properties.
-A all: view all files, including hidden files.
Drwxr-XR-x 2 root Root 4096 Jul 4 12:58
2 indicates the size of the group file to which the number of hard links belongs. It is not the exact creation time or last modification time.
A data block contains 512 bytes. The file system is the smallest unit for data storage.
The smaller the data block, the slower the read/write speed, and the smaller the data block, the larger the space wasted. You can adjust the size of data blocks as needed.
The number of hard links refers to the number of direct subdirectories in the directory, including. and .. therefore, if the number of hard links is 9, use LS-L to print 7 directories, while LS-LA to print 9 directories.
The first mark indicates the file type,
D Indicates directory
-Binary file
L soft link file link
R read
W write
X Execute
Each three characters is a part of a user.
Rwx R-x r-x
Owner U group G others
User Group others
Owner
2. Switch the directory CD [directory name] Change directory
PWD print working directory View Current Directory
3. Create a file touch [file name]
4. Create the directory mkdir [directory name] Make Directories
5. copy a file or directory CP-R [source file or directory] [target file or directory] Copy
CP-r copy directory
If you do not need the option to copy the file, you can directly copy the file using CP.
6. Move a file or directory MV [source file or directory] [target file or directory] Move
You can also use this command to rename a file.
MV file1 file2 # rename file file1 to file2. You can also add a directory name to cut the file to another directory and rename it.
7. delete a file or directory RM [file name] Remove
Here, an option-a is bound, that is, no inquiry. -F
Rm-RF [directory name]: directly delete all directories and files in the directory without asking. Applicable to many file scenarios.
Rm-R [directory name]
Deleting an empty directory rmdir [directory name] is not commonly used and has poor practicability.
8. You can use Ctrl + C to terminate a command at any time.
9. display the file content cat [file name] concatenate and display files
It is often used when there are few files (no more than one page, otherwise the last page will be stuck). It cannot display all the contents of a large file.
10. display all the content of the file by page. More [file name]
Space or F displays the next page
Enter: display the next line
Q or Q quit
11. display the first few lines of the file content head-num [file name]
The default value without adding a value is 10 rows.
12. display the last few lines of the file: tail-num [file name]
Same as above
Tail-f [file name] is used to monitor log files and dynamically display the latest file content.
13. Generate the link file ln-s [source file] [target file] Link
-S to generate soft link files
Soft links have the same meaning as shortcuts in windows.
The hard link is similar to the copy in windows, but not exactly the same. The files obtained from the hard link are synchronously updated with the source file, and all attributes are the same, while the copy is not. In addition, the file created by the hard link is the same as the source file, while the copy operation creates a new file. The Copy command CP-P can retain the original time value. A soft link is a symbolic link. If the source file is deleted, the soft link is meaningless. If the hard link still exists after the source file is deleted.
In Linux, any file to be processed by the Linux kernel must have a digital ID, because the kernel cannot recognize letters, but only numbers. The hard link is the same as the numeric identifier of the source file, while the soft link is different.
Ls-I is used to view the I node and inode of a file. Each file must have an I node, but not an I node can only correspond to one file. The hard link here is an example.
Hard links cannot be created across file systems, but soft links can.