1. Create a folder:
[[email protected] sm]# mkdir A Create a folder named a
2. Create file:
[[email protected] sm]# Touch a.txt Create a file named A.txt
3. Move the file (clip) (similar to cut)
[[Email protected] log]# mv b sm/ move the file (clip) b to the SM directory under the current directory
4. Delete
[[email protected] sm]# RM-RF a delete the A file -rf the shorthand for parameter-R -F
Parameters:
-R Recursive Delete
-F Force Delete
5. Renaming
[[Email protected] log]# mv b sm/c move the file (clip) bar B to the SM directory under the current directory and rename it to C
6. Copy
[email protected] sm]# CP sm.log . Copy the Sm.log to the parent directory [[email protected] log]# CP Sm.log . /sm01.log Copy the Sm.log to the parent directory and rename it to Sm01.log
7. View Files
[[email protected] sm]# cat sm.log View sm.log file contents [[email protected] sm]# Head sm.log View the first 10 lines of Sm.log file contents [[ Email protected] sm]# head-n sm.log View the first 20 lines of the contents of the Sm.log file [[email protected] sm]# tail sm.log< c16/> View the following 10 lines of the contents of the Sm.log file [[email protected] sm]# tail -n sm.log View the following 20 lines of the contents of the Sm.log file [[email protected] sm]# tail-f sm.log Dynamic View Sm.log file contents [[email protected] sm]# more Sm.log View the contents of the Sm.log in the form of a page turn (press SPACEBAR to flip, cannot be turned upside down) [[email protected] sm]# Less Sm.log View the contents of the Sm.log in the form of page flipping (press the up and down keys to page up and down, press Q to exit)
8. View Files
Basic syntax: Find find location Lookup parameters
Find. -name *java* Find files with Java characters in the current location find .-perm 777 Find files with permission 777 in the current location find / -user Ouyang Find the files in the system that the user is Ouyang find .-type d look for files of type folder in the current location
Find parameters:
-name-perm-user-group-ctime-type-size
9. Archive compression
[[email protected] java-run]# TAR-ZCVF log.tar.gz log/ Archive and compress the directory log, the archive compressed name is log.tar.gz [[Email Protected] java-run]# TAR-ZXVF log.tar.gz release and unzip log.tar.gz
You can use zip to compress files unzip extract files
Linux file Operations related commands