In this day and age, many users would probably say they have no reason to be exploring a command prompt; especially with all the richness of the graphical user interface (GUI) advancements over the past 20 years. True, but it doesn’t hurt to collect a few tricks or more, especially for those times you might be in a tight spot. The command line is an interface that provides all the same facilities as those found in the GUI. In fact, for many years, this is how users operated a computer; it was just a fact of life. Sure, it’s the exception today, but it’s a great way to brag to your friends about what you know. Plus, once you get comfortable with the command line, you may even prefer it to the GUI for some tasks.
Today, we take a look at several commands you should know. Let’s jump in.
Command Line Operations in Windows 10 Every User Should Know
The command line is similar to Alice in Wonderland—it can at times feel like a land full of wonder, mystery, and (possibly) danger. Our psyche has been so greatly changed by the power of the GUI, for many of us, the command line can feel primitive. But it shouldn’t and that’s why we are going learn some fun ways you can use it to perform some of the same tasks you normally do using point and click. Command line operations come in handy when you want to create scripts and automation tasks, too.
Before we begin, check out our previous article for instructions how to find and open the Command Prompt. Some of these commands call for administrator privileges, so, that’s a good way to start off our adventure.
1. List the Contents of a Folder and Clear the Screen
If want to see what’s listed in a folder when you open the command prompt, type dir (short for directory), then hit Enter. A list of the folder contents will be displayed, which might include files and other folders.
Depending on the folder, a lot of information might flash across your screen. When you want go back to a blank screen, type CLS to clear the screen.
2. Shutdown, Restart or Hibernate Your Computer
This is a task we perform every day: shutting down, restarting, sleeping or hibernating. Once you have the command prompt up on screen, just type in shutdown -s -t 01 to immediately power down your machine. You can change the timer to something longer. For instance, if you are performing a download and you know it will complete within a couple hours, you can change the timer to shutdown -s -t 7200 which is 2 hours in seconds. So, a little basic math is required. If you want to restart, type shutdown -r -t 01
Hibernation uses a different command, which requires a little memorization on your part. At the command prompt, type: rundll32.exe PowrProf.dll,SetSuspendState
Sleep uses a similar command, but users should be aware: when hibernation is enabled, this command does not work particularly well. So, you should disable hibernation first before running it. To do that, type powercfg -hibernate off at the command prompt, then you can run the following command to initiate sleep: rundll32.exe powrprof.dll,SetSuspendState 0,1,0
3. Create a User Account
The command line supports creating a user account too. You can even create accounts with specific privileges. This is how you do it.
Type: net user Username Password /add then hit Enter.
Example: net user John mypassword123 /add
You should see the following message: “The command completed successfully.” Click Start > username then switch to your new account.
If you want to add the user to a particular group such as Administrator, Power User or Limited User, use this command: net localgroup GroupPrivilege UserName /add
Example: net localgroup administrators Andre /add
4. Navigate File System Using Change Directory (CD) Command
In the graphical user interface, browsing and navigating through the File Explorer file manager is a simple point and click affair. The command prompt requires an argument when you need to change from one location to the next. When you open the Command Prompt with administrator privileges, it defaults to the System32 folder. To go back to your user folder, you need to take a few steps back by typing cd..
This will take you a step back, similar to the Up icon in the File Explorer window. When you are within the vicinity of a folder location, for example, drive C:\ you can type cd folder name to open the sub folder within. Here I can perform actions such as listing the contents of the folder using the dir command.
An even simpler method is to type the path to the folder you would like to navigate to. In my case, I want to go directly to my User folder named Andre from my current location, type: CD C:\Users\Andre then hit Enter. This immediately takes me to that desired location. If I want to go back to the System32 folder, I would type the path to its location also CD C:\Windows\System32. You can also go back to the root folder by typing CD\
5. Make, Move, Delete Folder and Files
Creating folders, copying and pasting files; these are everyday actions we perform in the graphical user interface. The command line can do it too. Here we have both the command line and File Explorer on screen and we have changed our directory to the folder called Sample located in Documents. Right now, the folder is empty, but we want to create a folder called Groovy to store some files.
In order to do that, at the command prompt, type md Groovy
This will create a folder in the location we just specified. If you want to create it somewhere else, use the CD command to navigate to that location. If you want to create more than one folder at once, just type md (make directory) followed by the name of each folder with a space between. Example: md Work Files. This will create two folders called Work and Files.
If you want to move the folder to a different location on the drive, this will require using the move command and knowing the path destination where you want the folder to be moved. Let’s give that a try. I want to move Work folder from the Groovy folder to the root of the Sample folder.
Type: move Work d:\Users\Andre\Documents\Sample
Deleting a folder is just as easy. In this case, I want to delete the folder called Files. At the command prompt type rd (remove directory) followed by the folder or file name. Example: rd Files
Deleting a file requires a different command. At the command prompt type del (delete) followed by the file name. Example: del win10uichanges.pptx
6. Copy, Paste, Rename Files
If something catastrophic happens to your computer and you need to recover your files, the copy command can be a lifesaver. The command line supports several types of copy commands:
- Copy: If you just want to copy files or folders from location to the other.
- Xcopy: A robust copy option suitable for copying the contents of a folder with subfolders to a destination folder. Xcopy is being superseded by Robocopy which provides the same functionality.
Here are some examples how to use these copy commands.
I want to copy the PowerPoint presentation named Evolution of the Settings interface.pptx to the Work folder located in the Groovy folder we created earlier. First, change your directory to the location of the file.
In my case, the PowerPoint file is in my User folder under Documents. First, type the copy command, followed by a file name with open and close quotes then the file path destination, example: copy “Evolution of the Settings interface.pptx” c:\Users\Andre\Documents\Sample\Groovy\Work
Since Robocopy has superseded Xcopy, we are just going to focus on using that command for this example. Robocopy includes a number of arguments you can use to copy lots of folders thoroughly. It’s particularly great for creating backups. For instance, if I want to make a backup copy of my Downloads folder to a folder on my thumb drive named Backup, this is how you do it.
robocopy “D:\Users\Andre\Downloads” “F:\Backup”
If you want to quickly recover the contents of a drive that won’t boot, this is one of the fastest and most reliable ways to do it. You can add other arguments for specific results, for example, /mir command added at the end of your command will ensure permissions from the source folder is maintained at the destination.
If you get an error System cannot find the file specified, the file name might be too long. Instead, try renaming the file using a shorter file name. To do that, type rename followed by the current file name then the new name, for example: rename “Evolution of the Settings interface.pptx” “win10uichanges.pptx”
7. Networking: IP Config, Ping, Tracert, DNS Flush
Network command line operations are available, too; there are quite a lot actually, but here are a few you should keep handy.
The ipconfig command is one you will likely come across from time to time. It’s used to view the IP address of your computer or network. Finding your IP address in the Windows GUI is easy, but buried; the command line is a faster way to find it. Just type ipconfig or ipconfig/all to view addresses of your network adapter. You can also use ipconfig to retrieve a new address. If you are on a business network, this can help resolve issues logging onto the network or accessing resources such as a mapped network drive.
At the command prompt, type ipconfig/release, hit Enter, type ipconfig/renew then hit Enter again.
Ping is used to check the status of a network address, which lets you determine if packets are being sent and received. A packet is a method of sending information along with its address over the network in small pieces, which is routed using different paths depending on the type of protocol used.
You can ping any website as long as you know the address. For example: ping www.groovypost.com
Tracert or Trace Route determines the route information takes to reach its final destination over the network. Similar to Ping, Tracert is most effective as a diagnostic tool when you are experiencing problems reaching a website. If I want to know the route it takes for my ISP to reach groovypost.com, all I need to type is tracert followed by the domain name or IP Address.
DNS Flush: DNS converts IP Addresses into simple names such as 22.214.171.124 into www.groovypost.com. Sometimes when you are unable to resolve an address, clearing your DNS cache can fix the problem. You can use the DNS Flush command ipconfig/flushdns.
8. Browse and Mount Network Share
In the DOS days and even when graphical user interfaces became popular, accessing network resources required command line knowledge. If you want to access a mapped network drive or shared folder over the network today, you can easily do it through Network and File Explorer. When connecting to network resources from the command line, the net use syntax is required followed by the \\MACHINE-NAME\NETWORKSHARE. In my example below, I want to connect to another computer named ELITEBK-INSIDER. If the network resource is password protected, you will be prompted to enter one along with a username. After connecting, you should see: “The command completed successfully.”
You can go ahead and browse the contents of the folder using the same commands we previously demonstrated.
If you want to connect to a specific subfolder over the network, you can use the pushd command followed by the network path, example: pushd \\ELITEBK-INSIDER\Wiki Projects. This is similar to change directory command.
9. Start an Application Install
You can also start an application install from the command line too. In fact, I recommend you give it a try when you experience problems with the GUI. Simply change to the directory then type the name of the application setup file followed by its extension.
10. DISM and SFC
DISM (Deployment Image Service and Management Tool) is a tool you can use to perform command line diagnostics on the health of your Windows 10 installation. It is primarily used in deployment scenarios, but for end users experiencing problems such as system stability or performance, DISM can help fix such issues. At the command prompt, type each of the commands one at a time, allowing the operation to complete in between.
Dism /Online /Cleanup-Image /CheckHealth
Dism /Online /Cleanup-Image /ScanHealth
Dism /Online /Cleanup-Image /RestoreHealth
System File Check tool is an oldie but goodie. This command line tool can be used in addition to DISM to scan and repair corrupted Windows system files. If it finds any corrupt files, it will restore a backup copy from a backup store in the System32 folder. To use it, just type sfc /scannow at the command line then hit enter. The process can take some time depending on the severity of the issue.
Bonus: View System Information, Format Partition Disks and Check Disks for Errors
We have covered these in detail before, so I won’t go into details—check our previous article on How to Find Your Systems Complete Specifications in Windows 10 for details to learn more. If you want verbose details about your system, such as initial date Windows 10 was installed, registered owner, BIOS version info, last time the system was booted, this is a great way to find it.
Working with disks through the command line is an important task you should learn too. We previously covered the steps how to format, partition and label disks using the built-in DiskPart command line tools. Check Disk is another import command line tool you should know since you can use it to diagnose and fix issues with your hard disks.
This is just the tip of the iceberg when using the command line. I don’t expect you to learn everything right away, but for the beginner or intermediate users, these can be quite a helpful introduction to learning its hidden powers.
Are there any particular commands I missed that you think should be a part of this tutorial? If so, let us know in the comments.