一 删除空目录
1、语法
rmdir [目录名]
命令英文含义:remove empty directories
2.实战
[root@localhost test]# mkdir test
[root@localhost test]# ls
test
[root@localhost test]# mkdir -p janpan/cang
[root@localhost test]# ls
janpan test
[root@localhost test]# rmdir test
[root@localhost test]# ls
janpan
[root@localhost test]# rmdir janpan
rmdir: failed to remove ?.anpan?.Directory not empty
二 删除文件或目录
1、语法
rm -rf [文件或目录]
命令英文含义:remove
选项:
-r:删除目录
-f:强制
2、实战
[root@localhost test]# touch abc
[root@localhost test]# rm abc
rm: remove regular empty file ?.bc?. y
[root@localhost test]# ls
janpan
[root@localhost test]# rm -r janpan
rm: descend into directory ?.anpan?. y
rm: remove directory ?.anpan/cang?. y
rm: remove directory ?.anpan?. y
[root@localhost test]# ls
[root@localhost test]# mkdir -p japan/cangls
[root@localhost test]# rm -rf japan
[root@localhost test]# ls
三 复制命令
1、语法
cp [选项] [源文件或目录] [目标文件或目录]
命令英文含义:copy
选项:
-r:复制目录
-p:连带文件属性复制
-d:若源文件是链接文件,则复制链接属性
-a:相当于 -pdr
2、实战
[root@localhost test]# touch abc
[root@localhost test]# cp abc /tmp/bcd
[root@localhost test]# ls /temp
ls: cannot access /temp:No such file or directory
[root@localhost test]# ls /tmp
bcd
[root@localhost test]# mkdir -p japan/can
[root@localhost test]# cp japan /tmp/
cp: omitting directory ?.apan?
[root@localhost test]# ls /tmp
bcd
[root@localhost test]# cp -r japan /tmp
[root@localhost test]# ls /tmp
bcd
japan
[root@localhost test]# ll
total 0
-rw-r--r--.1 root root 0Jul1219:31 abc
drwxr-xr-x.3 root root 16Jul1219:33 japan
[root@localhost test]# ll /tmp
-rw-r--r--.1 root root 0Jul1219:32 bcd
drwxr-xr-x.3 root root 16Jul1219:34 japan
[root@localhost test]# cp -a abc /tmp/
[root@localhost test]# ll /tmp
total 280
-rw-r--r--.1 root root 0Jul1219:31 abc
-rw-r--r--.1 root root 0Jul1219:32 bcd
drwxr-xr-x.3 root root 16Jul1219:34 japan
四 剪切或命名命令
1、语法
mv [源文件或目录] [目标文件或目录]
命令英文含义:move
注意:源文件和目标文件不在一个目录下,就是剪切,在一个目录下,就是改名。
2、实战
[root@localhost test]# ls
abc japan
[root@localhost test]# mv japan /tmp/japan
[root@localhost test]# ls /tmp
japan
[root@localhost test]# cd /tmp
[root@localhost tmp]# cd -
/root/test
[root@localhost test]# mv abc bcd
[root@localhost test]# ls
bcd