Linux file management command instance analysis [permissions, create, delete, copy, move, search, etc.]
This paper gives an example of linux file management command. Share with you for your reference, the details are as follows:
1. File permissions
Read r 4
Write w 2
Run x 1
Files are divided into three types of permissions:
User permissions within the owner permissions group and outside the group
2. View the files in the directory
Ls [option] [path or file name]
-l: view details
-a: view all files, including hidden files
First column: file permissions
-(rw-) (-)
The first character indicates the file type (- for ordinary files, d for folders)
The second one represents owner permissions.
The third indicates the group permissions to which he belongs.
The fourth indicates the permission outside the group.
Second column: number of file nodes
Third column: file owner
Fourth column: the group to which the file belongs
Fifth column: file size
Column 6: the last modification time of the file
Seventh column: file name
3. Directory management
Mkdir directory name create directory
-p Recursive creation
-m specify permissions when creating directories (linux default permissions for creating directories are 755)
Rmdir directory name delete directories (only empty directories can be deleted)
-p Recursive deletion
4. File creation and deletion
Touch filename creation file
Rm filename Delete Files (will prompt for deletion)
-r Recursive deletion
-f indicates shutdown confirmation
5. Copy and move files
Cp [option] Source file path destination file path copy file
-R: recursive replication
-p: keep the original attributes of the file during replication
-v: displays the replication process
> cp-R / home/user1/123 / home/. (. Indicates the use of the original file name)
Mv [options] Source file path destination file path move file
-v: display proc
> mv / home/user1/123 / home/.
* mv can also be renamed.
6. Document statistics
Wc [options] File list Statistics File content
-c statistics on the number of characters
-l count the number of rows
-w count the number of words
> wc-c 1.txt > wc-w 1.txt
7. Search for matching lines
Grep [options] string source file
-n display line number
-c how many lines are matched
-I ignore case
> grep-ni hello 1.txt
I hope what is described in this article will be helpful to the maintenance of Linux system.