The secret practices of ‘mkdir’ Every Linux freak must know
The Unix/Linux systems are widely being used with the emergence of cloud computing. It’s been really amazing to look around at the industry. Each and every work load is running on the Linux system.
It is also customary to use the mkdir command every now and then either via script or via ad-hoc command . But are you using it in right way ? The mkdir command allows to create directory ( commonly referred as folder in other operating system like windows) in the system. This command is executed to create one directory, multiple directory under one directory or multiple directory in specified path. It is also to be noted that the user executed this command should have enough permissions to avoid any permission errors. Let’s see what the official man page tells about the mkdir command.
The syntax of mkdir is
# mkdir [options...] [directories ...]
The parameter we can pass with this command is specified as
- v : It displays a message for every directory created.
Syntax :
# mkdir -v directory-name
- p : it helps to create a directory under specified path. Also it first check if the directory is to be created is already existing or not. If it doesn’t exist then only it creates it. If it exists then it doesn’t produce any errors. Without this parameter if you create a folder that is already been existing then it will obviously put some error.
However always make a habit of using -p while creating a directory in the Linux system and you can play safe like below image.
Another use with of mkdir with p and v parameter is shown as below.
Syntax :
#mkdir -p folder1/folder2/folder3
Also you can use mkdir commamd to create multiple folders under one directory.
Syntax :
#mkdir -p folder4 folder2 folder3
You can Check out with the other options available with mkdir like the other commands in Linux with below command.
Syntax :
#mkdir --help
I hope you like this article. Do Share your views and your valuable feedback. Thanks for your time.