一、mkdir新建目录
1、进入tmp目录,查看该目录下面的子目录
[[email protected] ~]# cd /tmp
[[email protected] tmp]# ls
hsperfdata_root ks-script-3CWMoc systemd-private-810f661cb5d247129113c096f86d7db2-cups.service-fEKfSx vitest yum.log
2、mkdir 创建test目录,然后查看
[[email protected] tmp]# mkdir test
[[email protected] tmp]# ls
hsperfdata_root ks-script-3CWMoc systemd-private-810f661cb5d247129113c096f86d7db2-cups.service-fEKfSx test vitest yum.log
3、批量创建目录
[[email protected] tmp]# mkdir -p test1/test2/test3/test4
[[email protected] tmp]# ls
hsperfdata_root ks-script-3CWMoc systemd-private-810f661cb5d247129113c096f86d7db2-cups.service-fEKfSx test test1 vitest yum.log
[[email protected] tmp]# cd test1
[[email protected] test1]# ls
test2
[[email protected] test1]# cd test2
[[email protected] test2]# ls
test3
[[email protected] test2]# cd test3
[[email protected] test3]# ls
test4
4、新建权限为rwx--x--x的目录
[[email protected] tmp]# mkdir -m 711 test2
[[email protected] tmp]# ls -l
total 4
drwxr-xr-x. 2 root root 17 Dec 16 01:18 hsperfdata_root
-rwx------. 1 root root 827 Dec 16 01:26 ks-script-3CWMoc
drwx------. 3 root root 16 Dec 21 20:52 systemd-private-810f661cb5d247129113c096f86d7db2-cups.service-fEKfSx
drwxr-xr-x. 2 root root 6 Dec 22 03:36 test
drwxr-xr-x. 3 root root 18 Dec 22 03:38 test1 原来目录的权限
drwx--x--x. 2 root root 6 Dec 22 03:40 test2 新建目录的权限
drwxr-xr-x. 2 root root 28 Dec 16 02:18 vitest
-rw-------. 1 root root 0 Dec 16 01:06 yum.log
二、rmdir 删除目录
1、删除目录test
[[email protected] tmp]# rmdir test
2、查看删除的结果
[[email protected] tmp]# ls -l
total 4
drwxr-xr-x. 2 root root 17 Dec 16 01:18 hsperfdata_root
-rwx------. 1 root root 827 Dec 16 01:26 ks-script-3CWMoc
drwx------. 3 root root 16 Dec 21 20:52 systemd-private-810f661cb5d247129113c096f86d7db2-cups.service-fEKfSx
drwxr-xr-x. 3 root root 18 Dec 22 03:38 test1
drwx--x--x. 2 root root 6 Dec 22 03:40 test2
drwxr-xr-x. 2 root root 28 Dec 16 02:18 vitest
-rw-------. 1 root root 0 Dec 16 01:06 yum.log
3、批量删除test目录下面的其他目录
[[email protected] tmp]# rmdir -p test1/test2/test3/test4
[[email protected] tmp]# ls -l
total 4
drwxr-xr-x. 2 root root 17 Dec 16 01:18 hsperfdata_root
-rwx------. 1 root root 827 Dec 16 01:26 ks-script-3CWMoc
drwx------. 3 root root 16 Dec 21 20:52 systemd-private-810f661cb5d247129113c096f86d7db2-cups.service-fEKfSx
drwx--x--x. 2 root root 6 Dec 22 03:40 test2
drwxr-xr-x. 2 root root 28 Dec 16 02:18 vitest
-rw-------. 1 root root 0 Dec 16 01:06 yum.log
二、cp的用法
1、将install.log复制到tmp目录下面去
[[email protected] tmp]# cp ~/install.log /tmp/install.log
[[email protected] tmp]# ls
hsperfdata_root install.log ks-script-3CWMoc systemd-private-810f661cb5d247129113c096f86d7db2-cups.service-fEKfSx test2 vitest yum.log
2、若目录已经存在,则+i覆盖cp
[[email protected] tmp]# cp -i ~/install.log /tmp/install.log
cp: overwrite ‘/tmp/install.log’? y
3、rm删除目录
[[email protected] tmp]# rm install.log
rm: remove regular empty file ‘install.log’? y
[[email protected] tmp]# ls
hsperfdata_root ks-script-3CWMoc systemd-private-810f661cb5d247129113c096f86d7db2-cups.service-fEKfSx test2 vitest yum.log
4、rm+i 避免删除错误
[[email protected] tmp]# rm -i install.log
rm: remove regular empty file ‘install.log’? y
5、强制删除空目录
[[email protected] tmp]# rm etc
rm: cannot remove ‘etc’: Is a directory
[[email protected] tmp]# rm -r etc
rm: remove directory ‘etc’? y
三、mv用法
1、创建install文件夹,然后将install.log文件移动到该目录下面去
[[email protected] ~]# cd /tmp
[[email protected] tmp]# cp ~/install.log install.log
[[email protected] tmp]# mkdir install
[[email protected] tmp]# mv install.log install
[[email protected] tmp]# cd /tmp/install
[[email protected] install]# ls
install.log
四、cat文件查阅用法
[[email protected] ~]# cat /etc/issue
\S
Kernel \r on an \m
五、touch用法
1、创建1个文件然后查看这个文件
[[email protected] tmp]# touch testtouch
[[email protected] tmp]# ls -al testtouch
-rw-r--r--. 1 root root 0 Dec 22 04:02 testtouch