'\" te .\" Copyright (c) 2007, 2011, Oracle and/or its affiliates.All rights reserved. .\" Copyright 1989 AT&T .\" Portions Copyright (c) 1982-2007 AT&T Knowledge Ventures .\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation.Original documentation from The Open Group can be obtained online at http://www.opengroup.org/bookstore/. .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation.In the following statement, the phrase "this text" refers to portions of the system documentation.Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group.In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document.The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.This notice shall appear on any product containing this material. .TH mkdir 1 "2011 年 7 月 27 日" "SunOS 5.11" "用户命令" .SH 名称 mkdir \- 生成目录 .SH 用法概要 .LP .nf \fB/usr/bin/mkdir\fR [\fB-m\fR \fImode\fR] [\fB-p\fR] \fIdir\fR... .fi .SH 描述 .sp .LP \fBmkdir\fR 命令在模式 \fB777\fR 下创建指定目录(可以通过文件模式创建掩码 \fBumask\fR(1) 更改模式)。 .sp .LP 目录中的标准条目(例如,目录本身的文件 “\fB\&.\fR” 以及其父目录的 “\fB\&. .\fR”)是自动生成的。\fBmkdir\fR 无法用名称创建这些条目。创建目录需要父目录中的写入权限。 .sp .LP 新目录的所有者 ID 和组 ID 分别设置为进程的有效用户 ID 和组 ID。\fBmkdir\fR 调用 \fBmkdir\fR(2) 系统调用。 .SS "setgid 和 mkdir" .sp .LP 要更改新创建的目录上的 \fBsetgid\fR 位,必须在执行了 \fBmkdir\fR 之后使用 \fBchmod\fR \fBg+s\fR 或 \fBchmod\fR \fBg-s\fR。 .sp .LP \fBsetgid\fR 位设置继承自父目录。 .SH 选项 .sp .LP 支持以下选项: .sp .ne 2 .mk .na \fB\fB-m\fR \fImode\fR\fR .ad .RS 11n .rt 用户可使用此选项指定要用于目录的模式。可供选择的模式可在 \fBchmod\fR(1) 中找到。 .RE .sp .ne 2 .mk .na \fB\fB-p\fR\fR .ad .RS 11n .rt 使用此选项时,\fBmkdir\fR 在创建 \fIdir\fR 时将先创建所有不存在的父目录。为中间目录指定的模式是 \fB777\fR 与文件模式创建掩码中设置的位数的差值。但是,该差值必须至少为 \fB300\fR(用户的写入和执行权限)。 .RE .SH 操作数 .sp .LP 支持下列操作数: .sp .ne 2 .mk .na \fB\fIdir\fR\fR .ad .RS 7n .rt 要创建的目录的路径名。 .RE .SH 用法 .sp .LP 有关 \fBmkdir\fR 遇到大于或等于 2 GB(2^31 字节)文件时行为的说明,请参见 \fBlargefile\fR(5)。 .SH 示例 .LP \fB示例 1 \fR使用 \fBmkdir\fR .sp .LP 以下示例: .sp .in +2 .nf example% \fBmkdir -p ltr/jd/jan\fR .fi .in -2 .sp .sp .LP 创建子目录结构 \fBltr/jd/jan\fR。 .SH 环境变量 .sp .LP 有关影响 \fBmkdir\fR 执行的以下环境变量的说明,请参见 \fBenviron\fR(5):\fBLANG\fR、\fBLC_ALL\fR、\fBLC_CTYPE\fR、\fBLC_MESSAGES\fR 和 \fBNLSPATH\fR。 .SH 退出状态 .sp .LP 将返回以下退出值: .sp .ne 2 .mk .na \fB\fB0\fR\fR .ad .RS 6n .rt 成功创建了所有指定目录或者指定了 \fB-p\fR 选项,所有指定的目录现在都已存在。 .RE .sp .ne 2 .mk .na \fB\fB>0\fR\fR .ad .RS 6n .rt 出现错误。 .RE .SH 属性 .sp .LP 有关下列属性的说明,请参见 \fBattributes\fR(5): .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . 属性类型属性值 _ 可用性system/core-os _ CSIEnabled(已启用) _ 接口稳定性Committed(已确定) _ 标准请参见 \fBstandards\fR(5)。 .TE .SH 另请参见 .sp .LP \fBchmod\fR(1)、\fBrm\fR(1)、\fBsh\fR(1)、\fBumask\fR(1)、\fBIntro\fR(2)、\fBmkdir\fR(2)、\fBattributes\fR(5)、\fBenviron\fR(5)、\fBlargefile\fR(5)、\fBstandards\fR(5)