The first step for any developers or those who want to do development work is to master the terminal and do everything through commands.
Because in the field of development you will always need to use the terminal or cmd. It doesn’t matter either you writing your code or want to push your project to GitHub or want to deploy your apps.
If the command prompt is your friend then you can do all these things very easily and believe me once get used to it then it will become handy to you.
Note: Don’t get confused if I use the word terminal, the terminal is available in Linux or Mac, and CMD or Command Prompt is used for windows. But they do the same work.
Therefore, in this article, I will walk you through the 14 Command Prompt commands for windows 10 which will make you more comfortable than before.
So without wasting too much time, let’s get started.
How to open Command Prompt?
Before knowing cmd commands you should first learn how to open cmd. Therefore learn it first in this section then we will learn commands in the next section.
I have told many times how to open the command prompt in my various articles. If you want to read some article related to command prompt then you can start with these articles:-
Related: [ Shortcuts for Run Command ]
BTW, follow these methods to open cmd:-
- Press Win + R altogether to open the run dialogue box.
- Type cmd and press enter. It will open Command Prompt for you.
- Click on the search bar which you will find on the bottom left corner of the taskbar of Windows 10.
- Then type command prompt and press enter.
You can use any one of the methods to open the command prompt both will work. Once you have opened it will look something like this.
14 Basics cmd or Command Prompt commands
I don’t want to fool you by simply giving you the list of commands, I have planned something for you. You can see the diagram below this is the folder tree on which I will work in this tutorial. And whatever I will teach you, same I will apply to this folder tree.
Type cd in the command prompt, it will list the present working directory of your computer. It means in which directory you are currently working. It is very important to know because after getting this information you will be able to decide in which directory you want to go.
Note: Directory means simply folder.
Once you have checked in which folder or directory you are. You can also get the list of folders inside the folder.
You have to simply type the dir command in cmd.
You see in the figures I have a total of 19 directories in the Desktop directory and also test1 and test2 are also present.
Let suppose, I want to go into the test1 directory, then run the next command
Replace the dir_name with the name of your folder. In my case I want to go into the test1 folder then I will simply type cd test1 and press enter.
As you can see, I am now in the test1 folder.
After doing all the above steps as you know I am currently in the test1 folder and I again want to go back in the Desktop directory the how can I achieve this?
Simply type the cd .. command, it will take me to the one level up.
There is a very special concept of an absolute pathname and relative pathname, .. is a relative pathname, and If you want to learn more about this then click here to read more.
As you can see I am again in the Desktop directory.
Now this time let’s go into the test2 folder which is also in the Desktop directory by typing the command cd test2.
At this time I want to open the test2 folder, then I will simply type start . because . represents the current directory. Since I am in the test2 folder, therefore, my current directory is test2 and it will open it.
Suppose I want to make a folder demo in the test2 folder, if you are reading this article from start then you know I am currently in the test2 folder.
I will simply run the mkdir demo and it will create a folder of name demo.
“echo > file_name.ext”
If you want to create the file then simply run the above command.
E.g. let say I want to create a text file name file1.txt then I will simply run the command echo > file1.txt and it will create a file with a specified extension in the current working directory and again you can check the current working directory by typing the cd command.
You can open the file very easily as you opened the folder, simply type start file1.txt and press enter. I will open the file.
Now after practicing these commands your command prompt will look messy and ugly and if you want to clean or clear the cmd the simply type cls and press enter. It will clear the terminal and your cmd will again start looking pretty.
For any reason, if you want to change the directory and want to go into the root directory then simply type cd / and press enter.
it will take you to the root directory and in most cases, the root directory is the C drive of our computer system.
As you can see previously I was in the test2 folder and after typing the command now I am in the root directory.
It is also one of the most important command prompt commands for windows 10 users.
“rename old_file_name name_file_name”
At this point in time, I have a file1.txt in my test2 folder and I want to change the name from file1.txt to file2.txt.
I can achieve this by simply running the command rename file1.txt file2.txt, and that’s it you have successfully changed the file name.
Note: You can also run this command to change the name of a folder.
If you want to delete the file then you can also do it by simply running the cmd command.
I want to delete the file named file2.txt which is in the test2 folder then I can run the below command to delete it.
file2.txt has been successfully deleted.
“rmdir folder_name” or “rmdir /s folder_name”
You have learned very interesting commands, and you also learned how to delete a particular file. But what if you want to delete the entire folder then you can run the below commands.
This is also one of the most important command prompt commands for windows 10 which you will use most of the time.
E.g. let’s say I want to delete the folder named test2, then first of all I will make sure that I am not in test2 by typing the cd command and after ensuring I will type rmdir test2 and press enter, it will do the work for me.
Note: rmdir folder_name will only delete the folder which is empty if you want to delete the non-empty folder then type rmdir /s folder_name and press enter, it will delete the non-empty folder.
And last but not least, if you want to close the command prompt then simply type exit and press enter command prompt will be closed.
There are hundreds and thousands of commands for command prompts but these are some basics command prompt commands for windows 10 which you should learn first.
Because it will build the foundation for you. And once you will start using it then soon you will also learn some advanced commands.
If you want to learn some advance commands then you can read these articles:-
Everyone wants to become a successful developer, it doesn’t matter which type of development you want to do either web development or android development or whatever. But if you have a solid foundation of how to play with the terminal then you will become a better developer.
If you like this article then please share it with your friends so that they can also take benefit of this article and you will also help me to reach more people.
Hii there, I am Shivam Kumar. Pursuing my B.tech degree in computer science. A computer geek, and founder of Tech Giant.