Linux basic commands for file and directory management
ls command
Function: Displays the contents of the target list or directory
Syntax: ls[option [directory or file]
-A: Displays all subdirectories and files in the specified directory, including hidden files
-L: Show file details
-D: Show directory
Example:ls-dl
650) this.width=650; "src=" Https://s1.51cto.com/oss/201711/19/536c4bf40f6118747bc52159515e7a03.png "style=" float: none; "title=" Image 1.png "alt=" 536c4bf40f6118747bc52159515e7a03.png "/>
CD command
Function: Used to switch work
Syntax: CD [directory]
Cd/etc
CD (return to current user's home)
Cd.. (Return to the previous level of the directory)
Example: cd/etc/123/
650) this.width=650; "src=" Https://s1.51cto.com/oss/201711/19/0213db2e036fe71e914984a285f4d442.png "style=" float: none; "title=" Image 2.png "alt=" 0213db2e036fe71e914984a285f4d442.png "/>
PWD Command
function: displays the path of the current working directory
syntax:pwd
Example:pwd
650) this.width=650; "src=" Https://s1.51cto.com/oss/201711/19/af5b7a1da2e13a2dddae50c373f38a66.png "style=" float: none; "title=" Image 3.png "alt=" Af5b7a1da2e13a2dddae50c373f38a66.png "/>
mkdir Command
Role: Create an empty directory
Syntax: mkdir [options] dirname
-M Sets directory permissions while creating a new directory, with default permissions of 755
-P: When creating a new directory, if the top-level directory to which you want to create the directory is not currently established, the upper -level directory is created
Example: Mkdir-p/p1/p2/
650) this.width=650; "src=" Https://s5.51cto.com/oss/201711/19/0894482eb7b9edf487500d05fbf90540.png "style=" float: none; "title=" Image 4.png "alt=" 0894482eb7b9edf487500d05fbf90540.png "/>
Touch command
Action: Modifies the creation date of a file or creates an empty file with the current system date
Syntax: Touch file1 file2 ...
Example: Touch a.txt
650) this.width=650; "src=" Https://s5.51cto.com/oss/201711/19/7b527ca33951812835e14a373867199a.png "style=" float: none; "title=" Image 5.png "alt=" 7b527ca33951812835e14a373867199a.png "/>
CP command
Role: Copy one or more source files to the target directory
Syntax: CP [option] source file or directory destination file or directory
-F: Overwrite if target file already exists without prompting
-I: Ask users before overwriting existing files
-P: Copy the modification time and access rights to the new file.
-R: If the source file is a directory, all subdirectories and files in that directory will be copied recursively, and the destination file must be a directory name
Example: CP a.txt/etc/123/b.txt
650) this.width=650; "src=" Https://s3.51cto.com/oss/201711/19/699f92db17bedb46963067775e53ea8f.png "style=" float: none; "title=" Image 6.png "alt=" 699f92db17bedb46963067775e53ea8f.png "/>
MV Command
Role: Renaming files or moving files from one directory to another
Syntax: MV [options] source file or directory destination file or directory
-F: Overwrite if target file already exists without prompting
-I: The opposite of the f option
Example:mv A.txt x.txt
650) this.width=650; "src=" Https://s4.51cto.com/oss/201711/19/ae4602ccdd2958408479e2dfe778c4d1.png "style=" float: none; "title=" Image 7.png "alt=" Ae4602ccdd2958408479e2dfe778c4d1.png "/>
RM command
Function: Delete one or more files or directories in a directory
syntax:rm [options] File
-F do not need to be confirmed to delete more than one file , you can bring a wildcard
-R removes all directories and subdirectories listed in the parameter recursively
-I for interactive delete
Example:rm-rf/etc/123/b.txt
650) this.width=650; "src=" Https://s3.51cto.com/oss/201711/19/746250448986a15843265d9e6829b859.png "style=" float: none; "title=" Image 8.png "alt=" 746250448986a15843265d9e6829b859.png "/>
Cat Command
function: Displays the contents of a file on the screen, or connects two or more files.
syntax:cat [ option ]< file name >
Example: Cat/etc/wj.txt
650) this.width=650; "src=" Https://s4.51cto.com/oss/201711/19/15adb4625d3e5b78d9dc93a51279c160.png "style=" float: none; "title=" Image 9.png "alt=" 15adb4625d3e5b78d9dc93a51279c160.png "/>
which command
Action: Displays the location of the application files
syntax:which [ file name ]
Example:which touch
650) this.width=650; "src=" Https://s4.51cto.com/oss/201711/19/6d2adc0170f1834e6d5135a8c10f00a1.png "style=" float: none; "title=" Image 10.png "alt=" 6d2adc0170f1834e6d5135a8c10f00a1.png "/>
Whereis Command
Function: Displays help information for a specified command or file
syntax:whereis [ file name ]
Example:whereis mkdir
650) this.width=650; "src=" Https://s1.51cto.com/oss/201711/19/795220318863469143d1b25b79f98069.png "style=" float: none; "title=" Image 11.png "alt=" 795220318863469143d1b25b79f98069.png "/>
grep command
Function: Finds the line that matches the specified keyword from a file and sends it to standard output.
Syntax: grep [options ] match pattern [ file ]
Example: Rpm-qa | grep vim
650) this.width=650; "src=" Https://s1.51cto.com/oss/201711/19/8ad2e77ca29cc47abc7b4e7241e68ed1.png "style=" float: none; "title=" Image 12.png "alt=" 8ad2e77ca29cc47abc7b4e7241e68ed1.png "/>
gzip command
role: File compression / decompression, does not support the compression of the directory, if the directory compression, the first package and then compress.
syntax:gzip [ options ] [ file name ]
-D: Unzip
-N: Specifies a compression ratio of 1-9, and does not specify a default of 6
-C: Writes the output to the standard output and retains the original file
Example:gzip a.txt(compression)
650) this.width=650; "src=" Https://s1.51cto.com/oss/201711/19/a7dfd3d820abc49d927b8e7af679ff04.png "style=" float: none; "title=" Image 13.png "alt=" A7dfd3d820abc49d927b8e7af679ff04.png "/>
Gzip-d A.txt.gz9 (Unzip)
650) this.width=650; "src=" Https://s1.51cto.com/oss/201711/19/3dad1ab0b5b9f03e079234628facd53b.png "style=" float: none; "title=" Image 14.png "alt=" 3dad1ab0b5b9f03e079234628facd53b.png "/>
This article is from the "New Network Society Blog" blog, please be sure to keep this source http://xwxhvip.blog.51cto.com/13020757/1983303
Basic commands for Linux file and directory management