This subchapter looks at mkdir, a UNIX (and Linux) command.
mkdir is used to make a directory.
make a directory
Use the mkdir command to make a new directory (folder).
$ mkdir testdir admins-power-mac-g5:~ admin$
multiple directories
You can name multiple directories with the mkdir command. Simply list each of the new diretcories after the mkdir with a space character between each directory name.
Use the -m option to create a directory with specific permissions. The permission chocies are the same as with the chmod command. Replace mode (a=rwx in the following example) with an appropriate mode argument. In the following example, themode is a=rwx, which would give all users read, write, and execute permissions.
This option is often used in shell scripts to lock down temporary directories.
use a path
You can give an entire path name to a specific directory, using either a relative or absolute path name to create the directory anywhere int he file system.
You can use the -p option to create directories along the path. You can therefore, create a series of parent and child directories all at once.
If you use the -p option and the directory already exists, the mkdir command will continue on through your path and create new directories as needed down to the last one you list.
Intermediate directories are created with the permission bits of rwxrwxrwx (0777) as modified by the current umask, plus the write and search permission for the owner.
view directories made
You can use the -v to get a list of the directories created. This is most often used with the -p option, but you can use it by itself.
The -v option is considered nonstandard and should not be used in shell scripts.
spaces in names
To create a directory with space in the directory name, you need to use quoting for the entire name so that the shell treats it as a single name rather than a series of individual directory names separeted by spaces.
While it is common to use spaces in file and directory names in graphic user interfaces (such as Macintosh, OS/2, and Windows, as well as Gnome or KDE), this may cause failure with older scripts or programs. Some programs may convert the spaces in a directory name into %20, such as converting " Name with spaces" into " Name%20with%20spaces" . This might cause confusion or failure.
long options
The long options are:
-m
--mode=MODE
-p
--parents
-v
-verbose
-Z
--context=CONTEXT
--help
--version
various operating systems
The mkdir command appears in the Linix, Mac OS X, OS/2, PC-DOS (also called MS-DOS), UNIX, and Windows operating systems. It also appears in the PHP programming language. In OS/2, PC-DOS, and Windows, the command can be abbreviated md.
history
The mkdir command appeared in Version 1 of AT&T UNIX. In early versions of UNIX, the mkdir command had to be setuid root because the kernel did not yet have a mkdir syscall. The mkdir command made a directory with the mknod syscall, followed by linking in the . and .. directories.
The mkdir syscall originated in 4.2 BSD and was added to System V in Release 3.0.
Coding example: I am making heavily documented and explained open source code for a method to play music for free almost any song, no subscription fees, no download costs, no advertisements, all completely legal. This is done by building a front-end to YouTube (which checks the copyright permissions for you).
Create your own copy from the original source code/ (presented for learning programming).
Work on this project is very slow because I am homeless. I am available for work if someone can provide an indoor place to work in Costa Mesa, California, electricity, internet connections, a flat raised working surface (such as a table or desk), a sitting device (such as a chair or stool), and a fully functional reasonably modern used computer. Im already homeless, so you dont need to pay me (and I understand how much business people hate the minimum wage law). Just give me a chance to work.
Building a free downloadable text book on computer programming for university, college, community college, and high school classes in computer programming.
If you like the idea of this project, then please donate some money.
send donations to: Milo
PO Box 1361
Tustin, California 92781
At the time I am homeless. This greatly interferes with my ability to create this project, which can help nearly 20 million U.S. college students and more than 150 million students world-wide. I am looking for 30 rich people or corporations willing to donate $10 a month to my church so that the church can provide a place indoors for me to continue work. If you want to donate, please see help project. Thanks much.
Supporting the entire project:
If you have a business or organization that can support the entire cost of this project, please contact Pr Ntr Kmt (my church)
UNIX used as a generic term unless specifically used as a trademark (such as in the phrase UNIX certified). UNIX is a registered trademark in the United States and other countries, licensed exclusively through X/Open Company Ltd.
Names and logos of various OSs are trademarks of their respective owners.