10 Command Lines Every Windows 10 User Should Know

Printer Friendly
Text Size: A A A A

http://www.groovypost.com/

The command line is an interface that provides many of the same facilities as those found in the graphical user interface (GUI). Once you become comfortable with the command line, you may even prefer it to the GUI for some tasks, such as scripts and automation. We will cover a few basic commands to get you started. Make sure you are running Command Prompt as administrator.

List the Contents of a Folder and Clear the Screen

 

If want to see a folder's contents, type dir (short for directory), then hit Enter. A list of the folder's contents will be displayed, including any files and nested folders.

Depending on the folder, a lot of information may flash across your screen. If you want go back to a blank screen, type CLS to clear the screen.

Shutdown, Restart or Hibernate Your Computer

 

Once you have the command prompt on screen, type in shutdown -s -t 01 to immediately power down your machine.

01 is the number, in seconds, until shutdown. If you want to extend the timer, increase 01 to a larger number. For example, if you are performing a download that you know will be complete within two hours, you can change the timer to shutdown -s -t 7200

If you want to restart, type shutdown -r -t 01

To hibernate type rundll32.exe PowrProf.dll,SetSuspendState at the command prompt.

Sleep uses a similar command. Users should be aware though, that when hibernation is enabled the sleep command does not work particularly well; so you should disable hibernation first before running sleep. 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

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

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 in the vicinity of a folder location, for example, drive C:\ you can type cd folder name to open the sub folder within. Here you can perform actions such as listing the contents of the folder using the dir command.

An easier method is to type the path to the folder you would like to navigate to. For example, if you want to go to your new User folder named Andre from your current location, type: CD C:\Users\Andre then hit Enter.

If you want to go back to the System32 folder, type the path to its location CD C:\Windows\System32. You can also go back to the root folder by typing CD\

Make, Move, Delete Folder and Files

 

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 type md Groovy at the command prompt.

This will create a folder in the location we 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. Try moving the Work folder from the Groovy folder to the root of the Sample folder by typing move Work d:\Users\Andre\Documents\Sample

Deleting a folder is just as easy. At the command prompt type rd (remove directory) followed by the folder or file name. For example, if you want to delete the folder called Files, type 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

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 one 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.

We 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 this case, the PowerPoint file is in Andre 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 you want to make a backup copy of your Downloads folder to a folder on your 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”

Networking: IP Config, Ping, Tracert, DNS Flush

 

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 we want to know the route it takes for the ISP to reach groovypost.com, all we need to type is tracert followed by the domain name or IP Address.

DNS Flush: DNS converts IP Addresses into simple names such as 104.24.11.25 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.

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 the example below, we 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.

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.

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 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.


For more information and to view an archive of previous Tech Tips, please visit us here.

Do you have specific topics you would like to see covered in Tech Tips? Email any suggestions to communications@ficpa.org.