In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the "mkdir command in linux use case analysis" related knowledge, small series through the actual case to show you the operation process, the operation method is simple and fast, practical, I hope this "mkdir command in linux use case analysis" article can help you solve the problem.
The linux mkdir command is used to create a directory with the specified name, requiring that the user creating the directory has write permissions in the current directory, and that the specified directory name cannot be an existing directory in the current directory.
1. Command Format:
mkdir [options] directory...
2. Command function:
The mkdir command allows you to create a folder or directory named dirname in a specified location. The user who wants to create a folder or directory must have write permission to the parent folder of the folder being created. Moreover, the folder (directory) created cannot have the same name as the file name in its parent directory (i.e. parent folder), that is, there cannot be a file name with the same name under the same directory (case-sensitive).
3. Command parameters:
-m, --mode= mode, set permissions (like chmod), not rwxrwxrwx minus umask
-p, --parents can be a path name. At this point if some directory path does not exist, plus this option, the system will automatically establish those do not exist directory, that is, a number of directories can be established;
-v, --verbose Displays information every time a new directory is created
--help Display this help message and exit
--version Output version information and exit
4. Command example:
Example 1: Creating an empty directory
Command:
mkdir test1
Output:
The copy code is as follows:
[root@localhost soft]# cd test
[root@localhost test]# mkdir test1
[root@localhost test]# ll
Total 4drwxr-xr-x 2 root root 4096 10-25 17:42 test1
[root@localhost test]#
Example 2: Recursive creation of multiple directories
Command:
mkdir -p test2/test22
Output:
The copy code is as follows:
[root@localhost test]# mkdir -p test2/test22
[root@localhost test]# ll
Total 8drwxr-xr-x 2 root root 4096 10-25 17:42 test1
drwxr-xr-x 3 root root 4096 10-25 17:44 test2
[root@localhost test]# cd test2/
[root@localhost test2]# ll
Total 4drwxr-xr-x 2 root root 4096 10-25 17:44 test22
[root@localhost test2]#
Example 3: Creating a directory with permissions 777
Command:
mkdir -m 777 test3
Output:
The copy code is as follows:
[root@localhost test]# mkdir -m 777 test3
[root@localhost test]# ll
Total 12drwxr-xr-x 2 root root 4096 10-25 17:42 test1
drwxr-xr-x 3 root root 4096 10-25 17:44 test2
drwxrwxrwx 2 root root 4096 10-25 17:46 test3
[root@localhost test]#
Description:
Test3 has permission rwxrwxrwx
Example 4: Creating a new directory displays information
Command:
mkdir -v test4
Output:
The copy code is as follows:
[root@localhost test]# mkdir -v test4
mkdir: directory "test4" created
[root@localhost test]# mkdir -vp test5/test5-1
mkdir: directory "test5" created
mkdir: Created directory "test5/test5 -1"
[root@localhost test]#
Example 5: A command creates a directory structure for a project
Reference:
Command:
mkdir -vp scf/{lib/,bin/,doc/{info,product},logs/{info,product},service/deploy/{info,product}}
Output:
The copy code is as follows:
[root@localhost test]# mkdir -vp scf/{lib/,bin/,doc/{info,product},logs/{info,product},service/deploy/{info,product}}
mkdir: directory "scf" created
mkdir: directory "scf/lib" created
mkdir: directory "scf/bin" created
mkdir: directory "scf/doc" created
mkdir: directory created "scf/doc/info"
mkdir: directory "scf/doc/product" created
mkdir: directory "scf/logs" created
mkdir: directory "scf/logs/info" created
mkdir: directory "scf/logs/product" created
mkdir: directory "scf/service" created
mkdir: directory "scf/service/deploy" created
mkdir: directory created "scf/service/deploy/info"
mkdir: directory "scf/service/deploy/product" created
[root@localhost test]# tree scf/
scf/
|-- bin
|-- doc
| |-- info
| `-- product
|-- lib
|-- logs
| |-- info
| `-- product
`-- service
`-- deploy
|-- info
`-- product
12 directories, 0 files
[root@localhost test]#
About "linux mkdir command use example analysis" content introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the industry information channel. Xiaobian will update different knowledge points for you every day.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.