[root@wyflinux tmp]# cd /tmp # 进入/tmp 目录,选择在tmp联系目录创建
[root@wyflinux tmp]# mkdir -p ./test1/test2/test3/test4 # mkdir -p 直接创建多级目录,(递回)
[root@wyflinux tmp]# ls -l # 检查是否创建成功
total 4
-rw------- 1 root root 0 Aug 30 11:39 AliyunAssistClientSingleLock.lock
drwx------ 3 root root 17 Aug 30 11:47 systemd-private-a63b0f54ab64483da7ecfa94742378dd-chronyd.service-6eItYg
drwxr-xr-x 3 root root 19 Sep 4 12:33 test1 # 发现目录test1 创建成功
-rw-r--rw- 1 root root 49 Aug 31 12:44 test1.txt
[root@wyflinux tmp]# cd ./test1
[root@wyflinux test1]# ls # 进入test1看下级子目录是否创建成功
test2
[root@wyflinux test1]# cd ./test2
[root@wyflinux test2]# cd ./test3/test4
[root@wyflinux test4]# pwd
/tmp/test1/test2/test3/test4 # 使用pwd命令检查,发现多级目录创建成功
[root@wyflinux test4]# rmdir ./test4
rmdir: failed to remove './test4': No such file or directory
[root@wyflinux test4]# cd .
[root@wyflinux test4]# cd ..
[root@wyflinux test3]# rmdir ./test4 # rmdir 只能单个删除目录,目录内容需为空
[root@wyflinux test3]# ls
[root@wyflinux test3]# pwd
/tmp/test1/test2/test3
[root@wyflinux test3]# cd /root/tmp/
-bash: cd: /root/tmp/: No such file or directory
[root@wyflinux test3]# cd /tmp
[root@wyflinux tmp]# ls
AliyunAssistClientSingleLock.lock systemd-private-a63b0f54ab64483da7ecfa94742378dd-chronyd.service-6eItYg test1 test1.txt
[root@wyflinux tmp]# rm -rf ./test1 # 逐级删除太慢,回到tmp 目录,直接rm -rf 删除 目录/test1及其名下的所以目录和文件,注意rm -rf 要慎用,小心误删
[root@wyflinux tmp]# ls -l # 检查是否删除成功,
total 4
-rw------- 1 root root 0 Aug 30 11:39 AliyunAssistClientSingleLock.lock
drwx------ 3 root root 17 Aug 30 11:47 systemd-private-a63b0f54ab64483da7ecfa94742378dd-chronyd.service-6eItYg
-rw-r--rw- 1 root root 49 Aug 31 12:44 test1.txt
#未见test1 目录, 删除成功