Linux Create And Remove Directory

Blogs ❯❯ Linux

Image could not load

Image by pixabay

अगर आप Linux use करते हैं तो , आपको कही न कहीं directories को create या remove करने की जरूरत पढ़ ही जायगी। इस blog में हम Linux में directories को create / remove करने के लिए की जाने वाली basic command mkdir और rmdir के बारे में बात करेंगे। And I Hope , आपको यह blog पसंद आएगा।

Linux mkdir Command

Linux में mkdir Command का use किसी directory को create करने के लिए किया जाता है। किसी directory को create करने के लिए आपको simply mkdir के बाद उस directory का name pass कर देना है।

mkdir dir-name

For Example -

$ mkdir my-dir
$ ls
my-dir

एक साथ कई directories create करने के लिए {from..to} syntax follow कर सकते हैं , जिसमे आप कोई number या letter pass कर सकते हैं।

Example -

$ mkdir dir_{1..5}
$ ls
dir_1  dir_2  dir_3  dir_4  dir_5  my-dir
$ mkdir dir_{a..d}
$ ls
dir_1  dir_2  dir_3  dir_4  dir_5  dir_a  dir_b  dir_c  dir_d  my-dir

Note: {from..to} में numbers और letters को आप mix करके use नहीं करके सकते हैं।

what is ls ?

Linux में ls command का use directories या directory contents को list करने के लिए किया जाता है। By default यह सभी visible files और directory को list करता है।

learn more about ls command ...

Linux rmdir Command

rmdir Command , mkdir के opposite है। Linux में rmdir Command का use किसी empty directory को remove करने के लिए किया जाता है। directory को remove करने के लिए आपको simply rmdir के बाद उस directory का name pass कर देना है।

rmdir dir-name

Example -

$ rmdir my-dir
$ ls
dir_1  dir_2  dir_3  dir_4  dir_5  dir_a  dir_b  dir_c  dir_d

ध्यान रहे कि remove की जाने वाली directory empty हो otherwise वो directory remove नहीं होगी।

non-empty directory को delete करने के लिए आप rm command को follow कर सकते हैं।

Linux remove multiple directories at once

asterisk (*) operator का use करके आप empty directories को एक बार में remove कर सकते हैं।

Example -

$ rmdir ./*
$ ls 
Recent Blogs

Loading ...

Rahul Kumar

Rahul Kumar

Hi ! I'm Rahul Kumar Rajput founder of learnhindituts.com. I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)

Get connected with me. :) LinkedIn Twitter Instagram Facebook