1.-p 选项
(1)mkdir -p 如果中间目录不存在,则创建它
应用示例:我们要创建一个目录linuxsir,并且linuxsir目录下包含子目录sirdoc,sirdoc目录下还有 redhat目录;
[root@localhost ~]# mkdir -p linuxsir/sirdoc/redhat
(2)rmdir -p 删除目录时是一级一级的时行的,值得注意的是,首先从最里面的目录开始。
应用示例:
[root@localhost ~]# mkdir -p linuxsir/sirdoc/redhat/
注:首先在当前目录下创建linuxsir目录,他的子目录是sirdoc,sirdoc内又有一个子目录redhat
[root@localhost ~]# rmdir -p linuxsir/sirdoc/redhat/ 注:删除linuxsir目录,要用到参数-p
[root@localhost ~]# ls linuxsir 注:检查一下是不是还有这个目录?
ls: linuxsir: 没有那个文件或目录
2.sync 命令
功能说明:将内存缓冲区内的数据写入磁盘。
语 法:sync [--help][--version]
补充说明:在Linux系统中,当数据需要存入磁盘时,通常会先放到缓冲区内,这个 buffer 是一块记忆体空间,等到适当的时刻再写入磁盘,如此可提高系统的执行效率。而系统如果在写磁盘前突然断电的话,那么资料就会流失了,sync 指令会将存于 buffer 中的资料强制写入硬盘中。
参 数:
--help 显示帮助。
--version 显示版本信息。
3.chdir函数
功 能: 改变工作目录
用 法: int chdir(const char *path);
示 例:chdir("/root");
4.access函数
NAME
access - determine accessibility of a file
SYNOPSIS
#include
int access(const char *path, int amode);DESCRIPTION
The access() function shall check the file named by the pathname pointed to by the path argument for accessibility according to the bit pattern contained in amode, using the real user ID in place of the effective user ID and the real group ID in place of the effective group ID.
The value of amode is either the bitwise-inclusive OR of the access permissions to be checked (R_OK, W_OK, X_OK) or the existence test (F_OK).
If any access permissions are checked, each shall be checked individually, as described in the Base Definitions volume of IEEE Std 1003.1-2001, Chapter 3, Definitions. If the process has appropriate privileges, an implementation may indicate success for X_OK even if none of the execute file permission bits are set.
RETURN VALUE If the requested access is permitted, access() succeeds and shall return 0; otherwise, -1 shall be returned and errno shall be set to indicate the error.
5.unlink函数 #include int unlink(const char * pathname); unlink()会删除参数pathname指定的文件。如果该文件名为最后连接点,但有其他进程打开了此文件,则在所有关于此文件的文件描述词皆关闭后才会删除。如果参数pathname为一符号连接,则此连接会被删除。 返回值 成功则返回0,失败返回-1,错误原因存于errno 错误代码 EROFS 文件存在于只读文件系统内 EFAULT 参数pathname指针超出可存取内存空间 ENAMETOOLONG 参数pathname太长 ENOMEM 核心内存不足 ELOOP 参数pathname 有过多符号连接问题 EIO I/O 存取错误