The mkdir Command
|
The mkdir command is is used to create new directories. A directory, referred to as a folder in some operating systems, appears to the user as a container for other directories and files. However, Unix-like operating systems treat directories as merely a special type of file that contains a list of file names and their corresponding inode numbers. Each inode number refers to an inode, which is located in inode tables (which are kept at strategic locations around the filesystem) and which contains all information about a file (e.g., size, permissions and date of creation) except its name and the actual data that the file contains. mkdir has the following syntax:
directory_name is the name of any directory that the user is asking mkdir to create. Any number of directories can be created simultaneously. Thus, for example, the following command would create three directories within the current directory (i.e., the directory in which the user is currently working) with the names dir_1, dir_2 and dir_3:
If a directory name provided as an argument (i.e., input) to mkdir is the same as that of an existing directory or file in the same directory in which the user is asking mkdir to create the new directory, mkdir will return a warning message such as mkdir: cannot create directory `dir_1': File exists and will not create a file with that name. However, it will then continue to create directories for any other names provided as arguments. It is necessary for a user to have write permission (i.e., permission from the system to create or change a file or directory) in the parent directory (i.e., the directory in which the new directory is to be created) in order to be able to create a new directory. Directories created by mkdir automatically include two hidden directories, one representing the directory just created (and represented by a single dot) and the other representing its parent directory (and represented by two consecutive dots). This can be seen by using the ls (i.e., list) command with its -a option, which tells ls to show all directories and files, (including hidden ones) in any directory provided to it as an argument, or in the current directory if there are no arguments, i.e.,
mkdir's -m option is used to control the permissions of new directories. New directories are by default created with the read, write and execute (i.e., run as a program if a program) permissions enabled for the owner (i.e., the creator of the directory by default) and group and the read and execute permissions enabled for other users. Thus, for example, to create a directory named dir_4 for which all three types of permissions were enabled for all users, the sequence 777 would be employed after -m, for example:
The first digit represents the owner, the second represents the group and the third represents other users. The number 7 represents all three types of permission (i.e., read, write and execute), 6 stands for read and write only, 5 stands for read and execute, 4 is read only, 3 is write and execute, 2 is write only, 1 is execute only and 0 is no permissions. Thus, for example, to create a new directory named dir_5 for which the owner has read and write permissions, the group has read permission and other users have no permissions, the following would be used:
The -p (i.e., parents) option creates the specified intermediate directories for a new directory if they do not already exist. For example, it can be used to create the following directory structure:
It is very easy to confirm that this series of directories has been created by using the du (i.e., disk usage) command with the name of the first directory as an argument. In the case of the above example this would be
Other options include -v (i.e., verbose), which returns a message for each created directory, --help, which returns brief information about mkdir, and --version, which returns the version number of the currently installed mkdir program. Additional information about mkdir can be obtained from the mkdir man page. Directories can be removed with the rmdir and rm commands. |
The mkdir Command的更多相关文章
- ./vi: line 2: mkdir: command not found
当前两天博主在写脚本的时候,运行脚本时候总是出现此消息,很郁闷, 开始我以为可能是我mkdir的函数库依赖的问题,但是当我用其他的脚本创建 目录的时候,命令又可以用了,找了半天,终于找到了答案 --- ...
- 在 Linux 下用 mkdir 命令来创建目录和子目录
mkdir 是什么呢 Mkdir 是一个用来在 Linux 系统下创建目录的命令.此命令属于内建命令. 运行 mkdir 命令 你可以在你的控制台直接键入 mkdir 来使用它. $ mkdir 默认 ...
- Linux学习之文件操作
Linux,一起学习进步- mkdir The mkdir command is used to create directories.It works like this: mkdir命令是用 ...
- DAY1 linux 50条命令
1. tar压缩,解压缩 tar -cvf *** (压缩) tar -xvf *** (解压缩) [root@bogon ~]# tar cvf test.tar test/ test/ test ...
- codecademy-command line_filesystem
$:shell prompt (命令提示符) In the terminal, first you see $. This is called a shell prompt. It appears w ...
- 【转载】linux内核启动android文件系统过程分析
主要介绍linux 内核启动过程以及挂载android 根文件系统的过程,以及介绍android 源代码中文件系统部分的浅析. 主要源代码目录介绍Makefile (全局的Makefile)bioni ...
- Google Code Jam 2010 Round 1B Problem A. File Fix-it
https://code.google.com/codejam/contest/635101/dashboard#s=p0 Problem On Unix computers, data is s ...
- Automake
Automake是用来根据Makefile.am生成Makefile.in的工具 标准Makefile目标 'make all' Build programs, libraries, document ...
- LVM学习
LVM Logical Volume Manager Volume management creates a layer of abstraction over physical storage, a ...
随机推荐
- 关于soapui简介与入门
SoapUI简介 SoapUI是一个开源测试工具,通过soap/http来检查.调用.实现Web Service的功能/负载/符合性测试.该工具既可作为一个单独的测试软件使用,也可利用插件集成到Ecl ...
- 阿里云云虚拟主机安装Z-BlogPHP
简介 在阿里云买了一个云虚拟主机,叫共享虚拟主机普惠版,6 块钱一年.本着练习上手的目的,尝试在阿里云云虚拟主机上安装Z-BlogPHP,一个个人建站的CMS 系统. 云虚拟主机网页空间为200M,M ...
- 51 Nod 1791 合法括号子段【分治+字符串】
1791 合法括号子段 基准时间限制:1 秒 空间限制:131072 KB 分值: 40 难度:4级算法题 有一个括号序列,现在要计算一下它有多少非空子段是合法括号序列. 合法括号序列的定义是: 1. ...
- HDU2504-又见GCD-递归
又见GCD Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submi ...
- Ajax及异步操作
之前我们使用的是jQuery的Ajax,这是一种极为便捷的Ajax操作方式,但是我们还需要对Ajax技术进行进一步的了解. <input type="text" id=&qu ...
- 算法-java代码实现基数排序
基数排序 第11节 基数排序练习题 对于一个int数组,请编写一个基数排序算法,对数组元素排序. 给定一个int数组A及数组的大小n,请返回排序后的数组.保证元素均小于等于2000. 测试样例: [1 ...
- async函数解析
转载请注明出处:async函数解析 async函数是基于Generator函数实现的,也就是说是Generator函数的语法糖.在之前的文章有介绍过Generator函数语法和异步应用,如果对其不了解 ...
- 微软Azure AspNetCore微服务实战第2期
2018年1月28日,虽然上海的大雪在城区已经见不到踪影,但还是很冷.不过天气再冷,也阻止不了小伙伴参加活动的热情. 感谢王振,苏老师以及微软Azure API Management的产品经理Alvi ...
- [转]【Java】内部类(Inner Class)如何创建(new)
简单来说,内部类(inner class)指那些类定义代码被置于其它类定义中的类:而对于一般的.类定义代码不嵌套在其它类定义中的类,称为顶层(top-level)类.对于一个内部类,包含其定义代码的类 ...
- myeclipse10不用打开myeclipse configuration center安装插件的方法
我使用myeclipse10,网上找了一大堆的插件安装方法,全部都是要通过help->myeclipse configuration center进行安装 不用打开myeclipse conf ...