20 best Command Prompt (CMD) commands you should know

tutorial
20 best Command Prompt (CMD) commands you should know

If you like the idea of working in a command-line environment and you’re just beginning to discover Command Prompt, there are some commands you should familiarize yourself with. There are CMD commands for almost everything, from working with files and directories to managing your system and network hardware. And some of those commands are better than others when it comes to getting the job done. That’s why, in this article, we rounded up what we believe are the best Command Prompt commands. Read on and learn them all:

Advertisement

System commands

Some of the best commands in Command Prompt are those that let you gather information, and control and manage your computer. These are commands that we call system commands, and the next ones are the best, in our opinion:

1. Logoff

Although signing out of Windows is an easy thing to do from the graphical interface, you might prefer the command line sometimes. And Command Prompt has a simple command just for that:

logoff

The logoff command

The logoff command

Run it, and you’re out. Logged out of Windows. 🙂

2. Shutdown

Maybe one of the most useful commands in Command Prompt. You can use it to shutdown, restart, log a user out, reboot into UEFI (BIOS), and you can even schedule after how much time any of these happen. To shut down your PC from CMD, run:

shutdown /s

The shutdown command

The shutdown command

For all the other uses of the shutdown command, read these guides we have published:

3. Tasklist

You probably know and sometimes use Task Manager to see processes running on your Windows computer. But did you know that you can also view processes in Command Prompt? There’s a simple CMD command for that:

tasklist

Use tasklist to view processes

Use tasklist to view processes

TIP: Here’s how to use the tasklist command to print the list of running processes in Windows.

Advertisement

4. Taskkill

In addition to the tasklist command, CMD also has another one that works in conjunction with it: taskkill. This command lets you kill (or stop, or terminate, if you prefer) processes. You’ll need to get the process name or process ID you want to kill using the previous command (tasklist), and then you can just run:

taskkill /f /im [process name]

or

taskkill /f /pid [process ID]

Use the taskkill command to end processes

Use the taskkill command to end processes

Here are more details about the tasklist and taskkill commands: View system information and manage processes from CMD or PowerShell.

5. Chkdsk

Is your hard-disk drive or SSD misbehaving, and you suspect data is corrupted? Then one of the best tools you can use to check your drive for errors and attempt repairing them is the chkdsk command. In CMD, switch to the drive you need to verify and repair, and run:

chkdsk /f

Run chkdsk to check your drives

Run chkdsk to check your drives

For more information on repairing drive errors, including with the chkdsk command, read: How to use Check Disk (chkdsk) to test and fix hard drive errors in Windows 10.

6. Sfc /scannow

While the previous command helps check errors on drives, when it comes to scanning the integrity of system files and repairing them, there’s another command you should use: sfc. Not only that it checks all essential files in the operating system, but it also replaces incorrect versions of them with the right ones. In Command Prompt, to scan your system drive, run:

sfc /scannow

The sfc command can be used to verify the system files

The sfc command can be used to verify the system files

For more details on how to use sfc in CMD, check this guide: How to repair missing or corrupt Windows files from the Command Prompt.

7. Format

In need to format a drive? Regardless of whether it’s a hard-disk drive, an SSD, or a USB memory stick, Command Prompt has you covered. Just use the following CMD command:

format [drive letter]: /fs:[file system] /q

… replacing [drive letter] with the letter of the drive you want to format, and [file system] with the type of file system you prefer. The /q argument allows you to do a quick format, but you can leave it out if you want to run a regular format. For example, here’s the command we ran to quickly format a USB memory stick with the drive letter h: using the NTFS file system:

format h: /fs:ntfs /q

How to format a drive from command line

How to format a drive from command line

Check the next command for more advanced formatting and drive partitioning options.

8. Diskpart

One of the most powerful tools in CMD is:

diskpart

Among others, it allows you to see, manage, create, and delete partitions from your drives. For example, you can enter diskpart and then run the list disk and list volume commands to see all the drives and volumes on your PC:

Diskpart is a powerful tool for managing drives

Diskpart is a powerful tool for managing drives

For all the details on how to use diskpart in Command Prompt, read: How to use diskpart, chkdsk, defrag, and other disk-related commands. This is a very useful tool if you need to work with Command Prompt to manage your drives, and especially so if you need to do it on a Windows computer that doesn’t boot.

9. Ver

Want to find out what version of Windows you use? Let Command Prompt help you identify the exact version and build of Windows. One of the easiest ways to get this information is to run this CMD command:

ver

Find out what version of Windows you have with the ver command

Find out what version of Windows you have with the ver command

If you have Windows 10 or Windows 11, you’ll need to understand what the version numbers shown by the ver command translate into. For that, check these articles: What is the latest version of Windows 10? Check the version you have! and How to check what version and edition of Windows 11 you have.

10. Systeminfo

Another CMD command that can be quite useful in certain situations is:

systeminfo

It collects and displays information about your computer hardware (like the processor, RAM, and network cards installed) and Windows installation (version, install date, hotfixes applied, etc.).

Gather information about your system with the systeminfo CMD command

Gather information about your system with the systeminfo CMD command

File commands

Some of the most basic commands you must know are the file commands. They’re essential if you want to navigate through the directories on your computer and be able to work with files and folders. We’ve covered file commands in this tutorial already: CMD: 11 basic commands you should know (cd, dir, mkdir, etc.). We recommend you to read it from start to finish, as the next couple of commands are just the tip of the iceberg:

Advertisement

11. Dir

If you need to work with files and folders in Command Prompt, the dir command is essential. Use it to list the contents of a directory so that you know what files and folders are in it:

dir

See what's inside a folder with the dir command

See what's inside a folder with the dir command

12. Cd

Cd is a basic CMD command that allows you to change the current directory. In other words, you use it to navigate to another folder on your PC. Its basic syntax is:

cd [path to folder]

Navigate through folders with the cd CMD command

Navigate through folders with the cd CMD command

13. Copy

Another basic command that fulfills a basic need in Command Prompt is copy. At some point or the other, while working in the command line, you will get to the point where you need to copy a file or two, or more, from one directory to another. Command Prompt has more than one command that helps you achieve that, but the main one and the one to start from is copy. Its syntax is simple:

copy [path\file.ext] [path\newfile.ext]

For example, we wanted to copy a file called digitalcitizen.txt to the same folder but bearing a different name: test.txt. For that, we had to run this command:

copy digitalcitizen.txt test.txt

How to copy files in Command Prompt

How to copy files in Command Prompt

For more details on how to copy files and folders in CMD, don’t forget to read the tutorial we shared at the beginning of this section.

14. Del

What if you want to erase a file you no longer need? Easy as pie: use the del command. In Command Prompt, all you need to do is type:

del

… followed by the name of the file you want to remove. Or, you can specify a folder’s name if you want to erase all the files in it.

How to delete files in CMD using the del command

How to delete files in CMD using the del command

Network commands

Some of the most interesting and useful CMD commands are the ones that help you manage and gather information about your network devices and connections. Out of all the commands you should know, which you can find detailed in this guide, here are the best ones:

15. Ipconfig

In Windows, there are many ways to find details about your network cards and connections. And one of the best methods is using the ipconfig CMD command. Ipconfig gets its name from Internet Protocol Configuration, and it’s a command designed to show and manage the IP addresses of your computer. In Command Prompt, run it like below, and you’ll get a full array of useful information like the IP, subnet mask, default gateway, hostname, MAC address, and DNS servers used by your PC:

ipconfig /all

Get NIC info with ipconfig in CMD

Get NIC info with ipconfig in CMD

16. Ping

Ping is the basic network-related CMD command you should use to test whether your PC can reach a destination device through the network and/or the internet. In Command Prompt, enter

ping

… followed by the IP address or hostname of the target device, website, or internet resource. For example, type:

ping digitalcitizen.life

… to check whether our website is up and running. 🙂

Ping a website or network resource from Command Prompt

Ping a website or network resource from Command Prompt

TIP: For more details on what ping is and how to use it, read this article: What is the ping command? What is ping in apps and games? How to use ping in Windows?.

17. Tracert

Sometimes, using ping is not enough to gather the information you need for troubleshooting network connectivity. In such cases, the more advanced command tracert (trace route) allows you to trace the path Internet Protocol packets take to their destination. This helps you identify where the problem is with more accuracy. The basic syntax for the CMD command tracert is:

tracert [IP address or hostname]

For example, if you want to trace the path of packets sent between your PC and our website, you’d run this command:

tracert digitalcitizen.life

Trace the path to a website or network resource from CMD

Trace the path to a website or network resource from CMD

18. Netsh wlan show profiles

The last network-related CMD command on our list is more specific, and it’s actually not just one but two commands, which you should run one after the other:

netsh wlan show profiles

and

netsh wlan show profile name=WiFi_SSID key=clear

The purpose is to help you find the password of a wireless network to which you’ve previously connected. Run the first command to see the list of known Wi-Fi networks. Note the name of the Wi-Fi for which you want to find the password, and run the second command replacing the WiFi_SSID with that network’s name. Once you press Enter, Command Prompt will tell you details about it, including its password. Neat, right?

Find the password of your Wi-Fi in CMD

Find the password of your Wi-Fi in CMD

CMD commands

Finally, we’re going to end this article with two commands that are useful for working with Command Prompt: a command that clears the screen and one that helps you understand what other commands do.

19. Cls

We’re nearing the end of this article, and if you’ve tried at least a couple of the previous commands, your Command Prompt window is now full of information. You’re in dire need of a clean slate to start over, right? Say hi to cls, Command Prompt's very own blackboard cleaner and one of the simplest commands in CMD. Run it, and the Command Prompt resets its window, clearing itself from previous commands and their output.

cls

CLS resets the Command Prompt

CLS resets the Command Prompt

20. Help

The last best CMD command you should know is help. Run it just like that, and you’ll get a list of essential commands you can run in Command Prompt and short descriptions for each of them. Type help followed by the name of a command you want to know more about, and Command Prompt will show you its syntax, use, and detailed description. So whenever you find yourself in need of help, run:

help

or

help [command]

Get help in Command Prompt

Get help in Command Prompt

What’s the best CMD command, in your opinion?

Now you know some of our favorite Command Prompt commands, as well as their uses. Do you have another one that you like most? Do you have something to add to this article or to recommend to other readers? Let us know in the comments section below.

Discover: Productivity Apps CMD Recommended Tutorials Windows