Although it’s typical to interact with the graphical user interface when using Windows, it’s still a good idea to know how to use the Command Line. If you dedicate the time to learning it, you could uncover a tool that can enhance your productivity, give you deeper control of Windows, and help you troubleshoot system issues without clicking too many things. You just need to know how to get started using it.
The Command Line might seem intimidating, but I’m here to walk through the basics. These basics will serve you well, whether you’re a student, professional, or just curious about Windows. Here’s what you need to know.
Windows Command Line Is Your Shortcut to System Control
Command Line interfaces, like Command Prompt or PowerShell, are utilities that allows you to control Windows using text commands. You will usually execute those text commands in a built-in interface known as Command Prompt (CMD). With the Command Prompt, you can save time navigating Windows’ graphical interface when performing tasks since many of them can be achieved with a single command.
You might even be able to do things that are not possible with clicks. For instance, you can access certain diagnostic tools and automations only through Command Prompt.
From now on, I will refer to the Command Line as Command Prompt, since that is what it’s usually called in the context of Windows.
Also, know that everything I discuss in this article can also be done in PowerShell, a more advanced Command Line than Command Prompt.
There are several ways to open Command Prompt, with the simplest method being to press the Windows key, type CMD, and hit Enter. Once it loads, you’re ready to start typing and running commands.
Basic Command Prompt Concepts
Upon opening a Command Prompt, you will see a file path (e.g., “C:UsersChifundo”). This is called the prompt, and it shows what directory you’re currently in. The blinking cursor at the end indicates that it’s ready to receive commands.
A command is the instruction you type in Command Prompt and press Enter to execute. Upon execution, it tells Windows to perform the action you have specified. Here is an example of a command that lists all the available commands and brief descriptions of what they do:
help
Some commands accept additional information (arguments) to carry out very specific operations. They might even be useless on their own if you don’t include the arguments—you might get an error or usage instruction. Here is an example:
cd ..
Here, cd is the command, which means change directory. The two dots (..) are the argument telling the prompt to move up one level. Once we execute this command, you will see the prompt has changed from “C:UsersChifundo>” to “C:Users>”.
An important thing to note is that commands are not case-sensitive in Windows. As long as you type in the right command, it doesn’t matter if it’s lowercase or uppercase. With that said, arguments may be case-sensitive, but this depends on the context in which they’re used.
Essential Commands for Beginners
Commands in Windows can be used for a wide range of functions. Here are the ones you need to know as a beginner.
Work With Directories in Command Prompt
As mentioned earlier, the cd command is for navigating between folders. If you wanted to move to the Documents folder, you would enter the following command:
cd Documents
Upon execution, you will see that the prompt has changed to “C:UsersChifundoDocuments.” Keep in mind that the folder you are navigating to has to exist in the directory for the command to work.
If you are not sure what files and folders are there, you can list them all with the dir (directory) command.
dir
You can create a folder using the mkdir (make directory) command followed by the name you want to give the newly created folder:
mkdir MyNewFolder
To delete a folder, you can use the rmdir (remove directory) command followed by the name of the folder.
rmdir MyNewFolder
Work With Files in Command Prompt
Just like with folders, you can perform operations on files using Command Prompt. For instance, if you wanted to create a blank file, you would enter the following command:
echo. > MyNewFile.txt
The command echo followed by a dot (.) instructs Command Prompt to generate an empty line. The right angle bracket (>) is an argument specifying that you want to send the empty line to a file. And MyNewFile.txt is the file to create (be sure to name it what you want).
You can also create a file with some text by following the echo command with a space and some text.
echo "Hello, Dexter Morgan" > MyNewFile.txt
You can also use the copy command followed by the source file and destination folder to copy and paste a file into another directory. Keep in mind that the destination folder must also already exist.
copy document.txt C:\MyNewFolder
You can also similarly move a file using the move command.
move document.txt C:\MyNewFolder
You can rename a file using the ren command followed by the old name and the new name.
ren MyOldName.txt MyNewName.txt
You can also delete a file using the del command followed by the file name.
del MyDocument.txt
View Network Configuration Information
I remember when I wanted to self-host a Nextcloud server on my Windows computer using Docker. I needed to know my IPv4 address so that other devices on my network could access it. I got it using the ipconfig command, which showed me the IP address I needed, as well as the subnet mask, default gateway, and other network configuration information I needed.
ipconfig
Test to Make Sure Your Network Is Working
Another important network command is ping. It helps you check if a website is down or if there is a problem with your network. It sends bits of information over the network and measures the response time in milliseconds, allowing you to tell whether the problem is on your end or not.
ping www.google.com
Important Troubleshooting Commands for Your PC
Is your computer’s drive being sluggish or crashing? You can easily scan and repair it using the Check Disk (CHKDSK) utility—it’s more handy for HDDs than SSDs. You can launch the tool from the Properties window of the problematic drive, but a quicker way is to just use the command below to save yourself extra clicks, or if you need to do it from the Advanced Startup Options menu.
Here is what the command would look like if I ran it on the local drive:
chkdsk /f c:
Another important troubleshooting utility is the System File Checker (SFC), which scans for and repairs corrupted Windows system files.
sfc /scannow
Then there’s the Deployment Image Servicing and Management (DISM) utility, which repairs the Windows image. It does a deeper repair of Windows when the SFC scan fails.
DISM /Online /Cleanup-Image /RestoreHealth
Command Prompt is a powerful Windows tool that can significantly boost your productivity, and it’s not hard to learn. Although initially intimidating, it can become an invaluable skill that gives you deeper control over your Windows system. Be sure to practice using it regularly so you can comfortably move on to advanced topics like automating tasks with batch scripts and unlocking even more of its power.