DEV Community

Cover image for Top cmd commands you must know if you are using windows
Kumar Kalyan
Kumar Kalyan

Posted on • Edited on

Top cmd commands you must know if you are using windows

Hi everyone, I am back with my new article.
The command line is a text interface for your computer.
It's a program that takes in commands, which it passes on to the computer's operating system to run and as a developer you must about these commands. Here, I will discuss about the commands we use in windows. Now there are a lot
of commands so I am going to discuss about the most used and this one is the first article of
this series. So, without wasting your time let's begin :D

md or mkdir

md or mkdir stands for make directory (also known as a folder)
so, this command will create a folder directly from the command line

mkdir <folder name>
Enter fullscreen mode Exit fullscreen mode

if you want to create Multiple folders in a single command use

mkdir <folder1> <space> <folder2>
Enter fullscreen mode Exit fullscreen mode

cd

cdstands for change directory, suppose you are inside folder A which consists two folders in it, viz, B and C respectively and you want to move in folder B so simply type cd B and you will move to folder B

C:\A>tree

C:.
├───B
└───C

C:\A>cd B

C:\A\B>
Enter fullscreen mode Exit fullscreen mode

cd/

To jump directly to the root folder of our command we use this command

C:\A\D>cd /

C:\>

Enter fullscreen mode Exit fullscreen mode

rd

rd stands for remove directory, suppose you want to delete a folder E which is present in folder B you can use rd E

C:\A\B>tree

C:.
├───E
├───F
└───G

C:\A\B>rd E

C:\A\B>tree

C:.
├───F
└───G
C:\A\B>
Enter fullscreen mode Exit fullscreen mode

tree

This command displays a tree like structure of all the directories and sub directories present in a particular directory

C:\A>tree

C:.
├───B
│   ├───F
│   └───G
└───D

C:\A>
Enter fullscreen mode Exit fullscreen mode

dir

this command displays the list of all the directories and files present in a particular directory

C:\A\B>dir

 Directory of C:\A\B

03-12-2021  22:40    <DIR>          .
03-12-2021  22:40    <DIR>          ..
03-12-2021  22:32    <DIR>          F
03-12-2021  22:32    <DIR>          G
03-12-2021  22:40                 0 hello.txt
               1 File(s)              0 bytes
               4 Dir(s)  266,177,257,472 bytes free
Enter fullscreen mode Exit fullscreen mode

type NUL

Suppose you want to create a file directly using the command prompt then you can use type NUL > <filename.extension>
see the example below

C:\A\B>type NUL > myName.txt

C:\A\B>dir

 Directory of C:\A\B

03-12-2021  22:51    <DIR>          .
03-12-2021  22:51    <DIR>          ..
03-12-2021  22:32    <DIR>          F
03-12-2021  22:32    <DIR>          G
03-12-2021  22:40                 0 hello.txt
03-12-2021  22:51                 0 myName.txt
               2 File(s)              0 bytes
               4 Dir(s)  266,176,991,232 bytes free

Enter fullscreen mode Exit fullscreen mode

del

this command you help to delete a particular file directly from the command prompt

C:\A\B>dir
 Volume in drive C is LocalDisk
 Volume Serial Number is 1809-3EA3

 Directory of C:\A\B

03-12-2021  22:51    <DIR>          .
03-12-2021  22:51    <DIR>          ..
03-12-2021  22:32    <DIR>          F
03-12-2021  22:32    <DIR>          G
03-12-2021  22:40                 0 hello.txt
03-12-2021  22:51                 0 myName.txt
               2 File(s)              0 bytes
               4 Dir(s)  266,176,991,232 bytes free

C:\A\B>del hello.txt

C:\A\B>dir
 Volume in drive C is LocalDisk
 Volume Serial Number is 1809-3EA3

 Directory of C:\A\B

03-12-2021  22:53    <DIR>          .
03-12-2021  22:53    <DIR>          ..
03-12-2021  22:32    <DIR>          F
03-12-2021  22:32    <DIR>          G
03-12-2021  22:51                 0 myName.txt
               1 File(s)              0 bytes
               4 Dir(s)  266,176,057,344 bytes free

Enter fullscreen mode Exit fullscreen mode

echo

Suppose you want to write something on a file that you just created directly using the command prompt the use echo <message> >> filename.extension

C:\A\B>dir


 Directory of C:\A\B

03-12-2021  22:53    <DIR>          .
03-12-2021  22:53    <DIR>          ..
03-12-2021  22:32    <DIR>          F
03-12-2021  22:32    <DIR>          G
03-12-2021  22:51                 0 myName.txt
               1 File(s)              0 bytes
               4 Dir(s)  266,176,057,344 bytes free

C:\A\B>echo My name is Kumar Kalyan. I am a CS student >>myName.txt

C:\A\B>dir


 Directory of C:\A\B

03-12-2021  22:53    <DIR>          .
03-12-2021  22:53    <DIR>          ..
03-12-2021  22:32    <DIR>          F
03-12-2021  22:32    <DIR>          G
03-12-2021  22:55                45 myName.txt
               1 File(s)             45 bytes
               4 Dir(s)  266,174,885,888 bytes free

C:\A\B>
Enter fullscreen mode Exit fullscreen mode

in the above example the size of myName.txt has increased to 45 byte after I have written something

Conclusion

SO that's all for this article, I will discuss about a few more commands in the next article. Feel free to post your comment if you have any doubts. and share this article with your peers if you like it.

Happy hacking :D

Top comments (0)