1, create a directory: mkdir
mkdir -p [directory name] -p recursively create command English original intent: make directories
Example:
[root @ localhost ~] # LS Anaconda-ks.cfg the Binaries-binaries.tar.gz Initial Setup-ks.cfg [root @ localhost ~] # mkdir test - to create a test directory can successfully create [root @ localhost ~] # LS Anaconda-ks.cfg the Binaries-binaries.tar.gz Initial Setup-ks.cfg the Test [root @ localhost ~] # mkdir test1 / test2 - neither test1 under the current directory, nor test2, can not successfully create mkdir: can not create a directory "test1 / test2": no such file or directory [root @ localhost ~] # mkdir -p test1 / test2 - use -p, recursively create [root @ localhost ~] # LS Anaconda-ks.cfg the Binaries the Binaries Initial Setup-the ks.cfg-.tar.gz Test test1 [the root @ localhost ~] # LS test1 test2
2, switching directory: cd
cd [directory] command English intent: change directory simplify operations cd ~ into the current user's home directory cd into the current user's home directory cd - entering the last directory cd .. enter the parent directory cd into the current directory.
Absolute and relative paths
Relative path: refers to the current directory lookup
[the root @ localhost ~] # CD ../usr/local/src/ [the root @ localhost the src] # CD ../usr/local/src/ - the relative path with reference to current directory to find the current location occurs before the change command may not be executed -bash: cd: ../usr/local/src/: no such file or directory
Absolute path: Specifies the start from the root directory, a recursive lookups level. In any catalog, you can enter the designated location
[root@localhost ~]# cd /etc/ [root@localhost etc]# cd /etc/
3, directory inquiry Location: pwd
pwd command English original intent: print working directory
[root@localhost etc]# pwd /etc
4, delete empty directories: rmdir
rmdir [directory name] command English original intent: remove empty directories
Example:
[the root @ localhost ~] # LS Anaconda-Binaries binaries.tar.gz the ks.cfg the ks.cfg Initial Test-Setup-test1 [the root @ localhost ~] Test # rmdir [the root @ localhost ~] # LS Anaconda-the ks.cfg Initial Setup-binaries.tar.gz-the Binaries ks.cfg test1 [root @ localhost ~] # rmdir test1 --rmdir only delete empty directories, if there are sub-directory under the file can not be deleted rmdir: delete "test1" failed: directory non empty
5, delete files or directories: rm
rm -rf [file or directory] command English original intent: remove options: -r delete a directory -f Force
Example:
rm
[root@localhost ~]# touch test3 [root@localhost ~]# ls anaconda-ks.cfg binaries binaries.tar.gz initial-setup-ks.cfg test1 test3 [root@localhost ~]# rm test3 rm:是否删除普通空文件 "test3"?y [root@localhost ~]# ls anaconda-ks.cfg binaries binaries.tar.gz initial-setup-ks.cfg test1
rm -r
[root @ localhost ~] # LS Anaconda-ks.cfg the Binaries binaries.tar.gz Initial Setup-ks.cfg-test1 [root @ localhost ~] # -r test1 RM RM: whether to enter the directory "test1" the y-? RM: delete directory "test1 / test2"? the y- RM: whether to delete the directory "test1"? y
rm -rf (execution -rf must know what you want to delete something is deleted is deleted, brought back, and even Linux can be identified rm -rf / command)
[root@localhost ~]# mkdir -p test1/test2 [root@localhost ~]# rm -rf test1 [root@localhost ~]# ls anaconda-ks.cfg binaries binaries.tar.gz initial-setup-ks.cfg
6. Copy command: cp
cp [option] [original file or directory] [destination directory] command English original intent: copy options: -r copy directories -p file attributes associated copy -d If the source file is a link file, then copy the link attribute -a equivalent -pdr
Example:
cp
[root@localhost ~]# cp anaconda-ks.cfg /tmp/ana [root@localhost ~]# ls /tmp/ ana
cp -r
[root@localhost ~]# ls anaconda-ks.cfg binaries binaries.tar.gz initial-setup-ks.cfg test1 [root@localhost ~]# cp test1/ /tmp/ cp: 略过目录"test1/" [root@localhost ~]# cp -r test1/ /tmp/ [root@localhost ~]# ls /tmp/ ana test1
cp -a
[root @ localhost ~] # ll total volume of 20172 -rw -------. 2165 the root the root. 1. 5-the ks.cfg Anaconda 16:15 dated 13 is drwxr-X-XR. 14 501 175 17 June 2017 games Binaries -rw-R & lt -. r-- the root. 1 the root. 6 20,647,102 dated 2017 binaries.tar.gz 22 is -rw-R & lt - r-- the root the root. 1. 5 dated 2213 13 16:17 initial-setup-ks. . CFG drwxr-XR-X.. 19. 3 the root the root test1 16:24 June 15, [the root @ localhost ~] # LL / tmp / total amount of 216 -rw -------. the root. 1 June 15, 2165 the root 16 : 22 ANA drwxr-XR-3 root root the X-19 16:25 test1 6 Yue 15. [root @ localhost ~] # DATE 2019 Nian 06 Yue 15 CST Saturday 16:45:11 [root @ localhost ~] # cp - Anaconda the ks.cfg-A / tmp / [the root @ localhost ~] # LL / tmp / total amount 220 -rw-------. 1 root root 2165 6月 15 16:22 ana -rw-------. 1 root root 2165 5月 13 16:15 anaconda-ks.cfg drwxr-xr-x. 3 root root 19 6月 15 16:25 test1
7, cut or rename command: mv
mv [original file or directory] [destination directory] command English original intent: move
Example:
[root @ localhost ~] # mv test1 / / tmp / test3 - does not require additional time to copy the directory -R & lt [the root @ localhost ~] # LS / tmp / ANA-Anaconda the ks.cfg test1 Test3
[the root @ localhost ~] # mkdir -p test1 / test2 [the root @ localhost ~] # LS Anaconda-Binaries binaries.tar.gz the ks.cfg the ks.cfg Initial-Setup-test1 [the root @ localhost ~] # Music Videos test1 / test123 - the source and target files in the same directory as the renamed command [root @ localhost ~] # LS Anaconda-ks.cfg the Binaries binaries.tar.gz Initial Setup-ks.cfg-test123