1) PWD: Show working directory path
Grammar:
PWD [Options]
Options:
The output link path when the-l directory is linked
-P Output Physical path
Example:
[Email protected] ~]# pwd
/root
Show current Path
2) CD: Change the working directory path
Grammar:
CD [options] [path]
Options:
-P If it is a connection path, enter the source physical path of the connection path
Example:
[Email protected] ~]# Cd/home
[Email protected] home]# pwd
/home
Switch to Home path
3) LS: Lists directory and file information
Grammar:
ls [options] [directory | file]
Options:
-a displays all subdirectories and files in the specified directory, including hidden files
-D If the parameter is a directory, only the period name is displayed and not the files and subdirectories below it
-F Display File types
-I displays the inode number of the file
-l display file details in long format
-R Reverse Order
-T Sort by modified time
-s sort by file size
Example:
[Email protected] data]# Ls/root
Anaconda-ks.cfg Install.log Install.log.syslog
Displays directories and files under the/root directory
4) Touch: Create an empty file, update the file timestamp
If the file does not exist, create a new file;
If the file exists, it changes the time stamp information such as the access time of the file atime.
Grammar:
touch [Options] [file]
Options:
-A Change access time only (Atime)
-M change file modification time record (mtime)
-C do not create a new file if the destination file does not exist
Example:
[[email protected] data]# touch/data/test{1..30}
[Email protected] data]# Ls/data
Test1 test12 test15 test18 test20 test23 test26 test29 test4 test7
Test10 test13 test16 test19 test21 test24 test27 test3 test5 test8
test11 test14 test17 test2 test22 test25 test28 test30 test6 test9
Create multiple contiguous files
5) mkdir: Create directory
Grammar:
mkdir [Options] [contents]
Options:
-p recursion to create a directory, the general first level directory does not exist when using-p, otherwise error
-V Displays information each time the directory is created
Example:
[Email protected] data]# mkdir-v/testdir
mkdir:created directory '/testdir '
Create a folder and display information
[Email protected] data]# mkdir-p/a/b/c/
[Email protected] data]# tree/a
/A
└──b
└──c
2 directories, 0 files
To create a folder recursively
6) RmDir: Delete Empty directory
Grammar:
rmdir [Options] [contents]
Options:
-p recursively deletes the directory and is deleted when its parent directory is empty after the subdirectory is deleted
-V Output Processing directory information
Example:
[Email protected] data]# mkdir-p/a/b/c/
[Email protected] data]# rmdir-pv/a/b/c/
rmdir:removing directory, '/a/b/c/'
rmdir:removing directory, '/a/b '
Rmdir:removing directory, '/a '
Rmdir:removing directory, '/'
rmdir:failed to remove directory '/': Device or resource busy
7) CP: Copy Files and directories
Grammar:
CP [Options] [Source file | directory] [target file | directory]
Options:
-A is equivalent to-DPR, preserving links, file attributes, and recursively replicating directories when replicating directories
-R recursively copy all subdirectories and files under directory
-F Force Delete, do not require user to confirm
-I require the user to go to the person before the operation
-L do not copy, just link file
Example:
[Email protected] data]# cp-r/boot/data
8) MV: Move file and directory paths, file and directory renaming
Grammar:
MV [options] [Source Files | directory] [target file | directory]
Options:
-I ask before overwriting
-F do not ask before overwriting
-N does not overwrite existing files
Example:
[Email protected] data]# MV/DATA/TEST1/DATA/TEST3
Test1 renamed to Test3
9) RM: Delete files or directories
Grammar:
RM [Options] [file | directory]
Options:
-F Force Delete
-R Recursively Delete directories and contents
-I need to confirm before deleting
Example:
[Email protected] data]# Ls/data
Boot Test2 test3
[Email protected] data]# rm-r/data/test2
Rm:remove directory '/data/test2 '? Y
[Email protected] data]# Ls/data
Boot Test3
WC: Number of rows, words, bytes, and characters of the statistics file
Grammar:
WC [Options] [file]
Options:
-L count rows
-W statistical number of words
-C Statistics byte number
-M statistic character number
The length of the longest line in the-l statistic file
Example:
[Email protected] data]# ls/root|wc-l
3
Shows the total number of directories and files under root and is 3
Summary of Linux commands (i)