Linux实用教程 第2版 教学课件 作者 於岳 编著 05.ppt
文本预览下载声明
5.3.4 touch:创建空文件、更改文件或目录时间 使用touch命令可以创建空文件以及更改文件或目录的时间。 命令语法: touch [-acfm][-d 日期时间][-r 参考文件或目录][-t 日期时间] [文件] 【例5.9】 创建空文件file,file1和file2。 【例5.10】 将文件file1的时间记录改为5月7日19点30分,时间格式为MMDDHHmm。 [root@PC-LINUX ~]# touch file1 [root@PC-LINUX ~]# touch file2 file3 [root@PC-LINUX ~]# ls -l file1 file2 file3 -rw-r--r--. 1 root root 0 6月 3 05:45 file1 -rw-r--r--. 1 root root 0 6月 3 05:45 file2 -rw-r--r--. 1 root root 0 6月 3 05:45 file3 //file1,file2,file3这3个都是空文件,文件内没有任何数据 【例5.10】 将文件file1的时间记录改为6月7日19点30分,时间格式为MMDDHHmm。 [root@PC-LINUX ~]# ls -l file1 -rw-r--r--. 1 root root 0 6月 3 05:45 file1 //空文件file1其创建日期为6月3日3:05 [root@PC-LINUX ~]# touch -c -tfile1 [root@PC-LINUX ~]# ls -l file1 -rw-r--r--. 1 root root 0 6月 7 19:30 file1 //可以看到文件file1现在的时间已经改为6月7日19点30分 5.3.5 mkdir:创建目录 使用mkdir命令可以在Linux系统中创建目录。 命令语法: mkdir [选项] [目录名] 【例5.11】 创建目录newdir1,其默认权限为755。 [root@PC-LINUX ~]# mkdir newdir1 [root@PC-LINUX ~]# ls -l 总用量 272 -rw-------. 1 root root 10670 6月 3 01:17 anaconda-ks.cfg -rw-r--r--. 1 root root 155641 6月 3 01:16 install.log -rw-r--r--. 1 root root 65450 6月 3 01:15 install.log.syslog drwxr-xr-x. 2 root root 4096 6月 3 05:46 newdir1 //目录newdir1的权限为rwxr-xr-x(755) 【例5.12】 创建目录newdir2,其权限为777。 root@PC-LINUX ~]# mkdir -m 777 newdir2 [root@PC-LINUX ~]# ls -l 总用量 276 -rw-------. 1 root root 10670 6月 3 01:17 anaconda-ks.cfg -rw-r--r--. 1 root root 155641 6月 3 01:16 install.log -rw-r--r--. 1 root root 65450 6月 3 01:15 install.log.syslog drwxr-xr-x. 2 root root 4096 6月 3 05:46 newdir1 drwxrwxrwx. 2 root root 4096 6月 3 05:47 newdir2 ………………………………………………………… //目录newdir2的权限为rwxrwxrwx(777) 5.3.6 rmdir:删除空目录 rmdir命令功能:删除空目录。 命令语法: rmdir [选项] [目录名] 【例5.13】 删除空目录newdir1。 [root@PC-LINUX ~]# rmdir newdir1 【例5.14】 同时删除/root/dir1,/root/dir1/dir2这两个空目录。 [root@PC-LINUX ~]# mkdir /root/dir1 [root@PC-LINUX ~]# mkdir /root/dir1/dir2 //创建目录/root/dir1和/root/dir1/dir2 [root@PC-LINUX ~]# rmdir -p /root/dir1/dir2 r
显示全部