Basic & Advanced Windows Command Prompt Commands.
Windows’ celebrated CLI (i.e., Command-Line Interpreter) is, without a doubt, a treasure trove of hidden features, tools, and settings. Although a bit off-putting given its lackluster GUI, Command Prompt lets you tap into every area of your Operating System, from creating new folders to formatting internal/external storage. To help you navigate cmd.exe like a pro, we’ve prepared this small, but a compressive list of Windows cmd commands. Enjoy and don’t forget to subscribe to our newsletter!
Getting Started with Command Prompt
Unsure about using cmd.exe? Not a problem; just follow this step-by-step guide to get started. First of all, you’ll need to fire up Command Prompt. Now, the easiest way to do that is by hitting
Windows Key + R and typing in
cmd in the Run window. Hit Enter and CMD will momentarily pop up on your screen. Of course, there’s more than one way to summon Command Prompt. For the second method, you’ll want to hit the
Windows key to bring up the Start Menu. After that, simply type in
command prompt in the search bar and left-click on the icon.
To sum up…
Windows key + R -> type
cmd -> press Enter
Windows key -> type
command prompt -> left-click on the CMD icon.
Now that Command Prompt is up and running, it’s time to have some fun. We’re going to start with a couple of basic commands and then move on to the more advanced stuff.
Basic Windows CMD Commands
Ver– displays operating system version on the screen (e.g., Microsoft Windows [Version 10.0.19045.2486])
Date– displays the current date on the screen. Can also be used to change the date.
Shutdown– shuts down your machine.
Taskkill– allows you to terminate a process or a running app. To use this, type in
taskkillfollowed by ‘/f’, ‘/im’, and the name of the process or app you want to terminate (e.g. winword.exe). So, if we want to kill all instances of MS Word, we would need to type in
taskkill /f /im winword.exe. Hit Enter to confirm.
Color– changes the color of the foreground and background. For instance, typing in ‘color fc’ will make the background bright white and the foreground (i.e., writing) light red.
Getmac– displays your machine’s MAC address.
Ipconfig– displays your IP address.
Ping– sends data packets to a specific IP address or network (e.g.,
ping google.com). Very useful in troubleshooting Internet connectivity issues.
Pathping– maps the connection to a specific IP address. Can also be used to troubleshoot connectivity issues.
Nslookup– displays the DNS record or IP address of a specific domain (e.g.,
Chkdks– performs a routine check on a specified disk and corrects errors.
Gpupdate– updates group policies. Usually used in conjunction with the force (/f) argument.
Mkdir– creates a new directory.
Tasklist– displays a list of all live processes and applications.
Timeout– very useful when working with batch files. This command allows you to delay execution for a specified number of seconds. When appended the -1 value, process execution will be delayed indefinitely. The computer will wait for a keystroke to continue.
Type– this command allows you to view text files (.txt) in your cmd window.
Vol– displays disk volume information such as serial numbers or labels.
Systeminfo– displays useful sys info such as Host Name, OS version, processor, BIOS version, time zone, applied hotfixes, and more.
Netstat– displays info about active TCP connections.
Help– outputs a list of commonly used commands.
Advanced Windows CMD Commands
And now it’s time to lose the kid gloves and talk about some more advanced (and cool) CMD commands.
Telnet– allows you to establish a remote, Telnet-type connection. Before attempting to ‘dial’, ensure that both machines support Telnet communication and that the client software is installed. To initiate this type of remote session, you must specify the IP address of the server or the main computer followed by 13531 (e.g. telnet 126.96.36.199 13531). The number at the far end of the command represents the communication port used by the Sage 50 Connection Manager. If the setup’s done right, your CMD cursor should become blank. Otherwise, it will return the message “telnet is not recognized as an internal or external command, operable program, or batch file”. This error message appears when Telnet’s not enabled on the machine. To switch it on, click on the Start button and head to Control Panel. Under Programs and Features, select Turn Windows Features on or off. Scroll down until you see Telnet Client and Telnet Server. Enable both features and click the Ok button to confirm. Restart your machine. Open a new CMD window and retry the connection.
Klist– this command allows you to visualize cached Kerberos tickets and retrieve useful information such as encryption type, server, start time, renew time, session key type, cached flags, and more.
FC– changes made to files may not always be obvious. To see if a file has been modified, use the File Compare (FC) command in CMD. You can perform two kinds of file comparisons: ASCII or binary. For instance, you may want to use an ASCII-type comparison when working with a text file. On the other hand, for media (e.g. pictures, clips, etc.) a binary comparison would be the proper approach.
Powercfg– this is a great diagnostic tool for laptop users. Ever wondered why your battery’s running out so fast, leaving you high and dry, possibly in the middle of an (important) e-meeting? Well, you can quickly find out by running this Power Configuration utility in CMD. Powercfg usually works best with the ‘-energy’ argument. So, after running the combo ‘powercfg -energy’, your machine will begin a 60-second power test. It will generate a power efficiency diagnostic report. If any errors are found, they will be highlighted in the second section of the report, along with recommendations.
Cacls– this nifty command allows you to display or modify ACLs (i.e. Access Control Lists) of various files. Some of its more popular uses include granting specific access rights to users (i.e. Read, Write, Change, or Full Control), revoking permissions, denying specific users, or replacing the user’s access rights. Here’s a quick example of how to use the Cacls command.
Step 1. Create a text document on your desktop area. Name it ‘test.txt’
Step 2. Open CMD.
Step 3. Navigate to the Desktop directory by typing in ‘cd desktop’
Step 4. Type in ‘cacls test.txt’. This will display users and permissions.
Step 5. In this example, we will update (replace) the default rights of user BUILTIN\Administrators from F (i.e. Full Control) to R (i.e. Read only) using the /P argument.
Step 6. Type in ‘cacls test.txt /P BUILTIN\Administrators: R
Step 7. Type ‘Y’ and press Enter to confirm changes.
ARP – display or commit changes to the ARP cache. To view the contents of the cache, type in ARP -a and press ENTER. If you want to make changes to the ARP cache such as adding a static entry use ARP-a, followed by the Internet address (i.e. IP) and the physical address (i.e. MAC). For instance, if we have a new host and want to associate its IP to its physical address, we will need to type in the following line: ARP-a [IP_address] [Physical_Adress].
Chgport – use this command to display or remap COM ports.
Cipher – check the encryption status of your files or folders (i.e., NTFS partitions only).
Cmdkey – displays and allows you to make modifications to all host-stored passwords and usernames.
Dispdiag – allows you to diagnose display-related issues. Can create log dump files when used together with the [-d] argument.
Driverquery – displays a list of all the drivers installed on the machine.
Fondue – install optional MS Windows updates from CMD.
Hwrcomp – this command allows you to install or update existing handwriting recognition dictionaries.
Makecab – used to compress files and folders.
Mrinfo – displays router interface info.
Pentnt – this command allows to user to detect so-called floating-point division errors in Pentium processors.
Reagentc – use this command to configure the Windows Recovery Environment.
Recover – retrieve data from a bad disk.
Repair-bde – useful in decrypting/repairing a damaged drive that’s been encrypted with BitLocker.
20. Runas – execute an application with another user’s credentials.
BONUS – Raining Code
To be true to the saying “all work and no play (…), here’s how you can make your CMD ‘rain’ code. It doesn’t do anything useful, but it sure looks cool. Enjoy!
Step 1. Create a fresh .txt file on your desktop.
Step 2. Open it and paste the following code:
@echo off color 0a :top echo %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% goto top
Step 3: Save as .bat.
Step 4: Run the .bat file as admin and watch it pour code.
Note: if nothing’s happening, go back and edit the file. Use Notepad or Notepad++ to open it. Ensure that all instances of %random are on the same line.
This concludes the article on the best Windows Command Prompt commands. Hope you’ve enjoyed it. For any questions or additions, be sure to hit the comments section. Be seeing you! Don’t forget to stay safe, take it easy, and subscribe to Heimdal®’s newsletter for more goodies.