Everything Linux system follows the rules of operation of the file. I would like to make good use of the Linux system, it is necessary to master the operation of related files.
1, create a file command: touch
Syntax: touch filename #filename file name.
For example, touch hello.txt will create a file in the current hello.txt of wood.
Description: By the time touch command to create a file, if the current directory has the same name as the file exists, the command does not modify the contents of the original file of the same name, but it will modify the properties file creation time.
2, delete the file command: rm
Syntax: rm filename #filename indicates the file name
For example: rm hello.txt # This command deletes the current directory the file name is hello.txt file.
Description: delete the file command, the system will confirm the operation, the implementation of Y will really delete files, or cancel the deletion. This is the Linux system to prevent accidentally deleted a file validation mechanism provided.
3, the command to move or modify the file name: mv
Syntax:
mv filename you
# Filename represents the file you want to move, dir represents the directory you want to move to (move only the file directory)
mv filename filenamenew
# Filename represents the file you want to move, filenamenew representation (only modify the file name) to modify the new file name
mv filename dir/filenamenew
# Filename represents the file you want to move, dir represents the directory you want to move, filenamenew pledged to modify the new file name (directory name while moving the modified file)
For example: mv hello.txt / home # hello.txt move the file to the home directory
mv hello.txt hello.doc # hello.txt modify the file named hello.doc
mv hello.txt /home.hello.doc # hello.txt modify file named hello.doc, and move the file to your home directory.
Description: mv command also applies to the operation of the directory, because Linux file system directory is also considered.
4, view the file name: cat
Syntax: cat -n filename #filename file name, -n optional parameter can be used to explicitly contents of the file line number
For example: cat hello.txt
5, view the contents of the file header: head
Syntax: cat -n filename #filename file name, -n optional parameter can be used to specify a line number, the default is 10 lines.
For example: head hello.txt
Application: general for large files, just want to view the contents start of the file.
6, see the end of the file content: tail
Syntax: tail -n filename #filename file name, -n optional parameter can be used to specify a line number, the default is 10 lines.
Description: This command and the head command is very similar, it is mainly used to view the contents of the file tail. It is in the actual process is very practical and can dynamically view the contents of the file tail. For example, you deploy a tomcat server site, the site there is a problem we need to see tomcat, tomcat log files are sometimes large, this time you can use the tail command, dynamic view the latest error message.
Reproduced in: https: //www.jianshu.com/p/39cc287027ed