[go: up one dir, main page]

0% found this document useful (0 votes)
13 views3 pages

Mkdir Command Guide

Guide to arch linux

Uploaded by

Divine
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views3 pages

Mkdir Command Guide

Guide to arch linux

Uploaded by

Divine
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Understanding 'mkdir' Command in Linux

The `mkdir` command in Linux (and other Unix-like operating


systems) stands for "make directory".
It is used to create new directories (folders) in the file system.

Syntax
------
mkdir [OPTION] DIRECTORY_NAME

- DIRECTORY_NAME: This is the name of the directory you want to


create.
- [OPTION]: Optional flags to modify how the command works.

How it Works
------------
When you run the `mkdir` command, it creates a new directory at the
location you specify.
If no location is specified, the directory is created in your current
working directory (the folder you're currently "in" in the terminal).

Example: Basic Usage


--------------------
1. To create a directory named `my_folder`, you would run:
mkdir my_folder
This creates a folder named `my_folder` in your current directory.

2. If you want to create the directory somewhere else, specify the full
path:
mkdir /home/user/documents/my_folder
This creates `my_folder` inside the `/home/user/documents/`
directory.

Common Options for `mkdir`


--------------------------
- `-p` (parents): Create parent directories if they don't exist. For
example:
mkdir -p /home/user/documents/folder1/folder2
If `folder1` doesn't exist, this command will create both `folder1` and
`folder2`.

- `-v` (verbose): Show a message for each created directory:


mkdir -v my_folder
The output will be something like:
mkdir: created directory 'my_folder'

Error Handling
--------------
- If the directory already exists, you'll get an error message:
mkdir: cannot create directory 'my_folder': File exists
- If you don't have the required permissions to create the directory in
a certain location, you'll get a permission denied error:
mkdir: cannot create directory '/restricted_folder': Permission
denied

In this case, you might need to use `sudo` for administrative


privileges:
sudo mkdir /restricted_folder

You might also like