The Windows Command Prompt may seem so old-school right now, but it’s still a very powerful tool with a few hacks, tips and tricks up its sleeve.
In this article:
- How to Open Command Prompt
- Command Prompt Hacks to Get Work Done Faster
- More Cool Command Prompt Tricks | Nifty Shortcuts
- More Things You Can Do in the Command Prompt
9 Cool Command Prompt Tips and Tricks You Can Do Right Now
How to Open Command Prompt
To open your command prompt, click on the “Start” button (or tap on the “Windows” key) and type “cmd” in the search bar. The Command Prompt shortcut should be the first entry on the list.
Another way to run the command line is through the “Run Command” dialog. Press “Windows” + “R” to open the Run Command dialog, type “cmd,” then press “Enter.”
Command Prompt Hacks to Get Work Done Faster
1. Run a Command Prompt as Administrator
Some commands require you to open Command Prompt as an administrator. To do this, right-click on the Command Prompt shortcut and click the “Run as Administrator” option.
You know you’ve followed the steps correctly and the CMD shell is running in Administrator mode when you see the word “Administrator: Command Prompt” on the title bar.
2. Abort a Command
If you accidentally entered the wrong command, you can press “Ctrl” + “C “to stop it immediately. This doesn’t magically undo things (like that format command you accidentally started), but for other things like a dir command loop, it’s a good thing to have a stop button when you need it.
3. Save Command Line Output to the Clipboard
It’s a little tricky to save command line output to a file if you tried to select the entire command prompt screen. However, there are a couple of commands you can have at your disposal to easily save them when you need to.
Here’s a command you can use to save command output to the clipboard for later use.
To do this, append <space>| clip to the command you want to save the output for. For example, if you want to save system information to the clipboard, key in systeminfo | clip on the Command Prompt.
4. Use Redirectors to Save Output to a File
If you need to save this output to a file, there are these nifty characters called redirection operators (in this case, the > and >> operators) that allow you to save command line output to a text file. This makes it handy if the command output is particularly long and you need to save it for later.
The main difference between the > and >> operators is:
- With the > operator, if a file with that specific name and that specific path exists, the contents of the text file get overwritten.
- With the >> operator, if the file already exists, the command prompt appends the contents into the existing text file.
Going back to our system information example, you can execute systeminfo > c:\computer_info.txt, which would then execute the system information command and save its output to a text file named computer_info.txt.
4. Run Multiple Commands at the Same Time
If, for any reason, you need to run two commands at once, just put “&&” between each command. This should shave off some typing time.
More Cool Command Prompt Tricks | Nifty Shortcuts
5. Function Keys
Function keys allow what are otherwise tedious tasks to be completed with just one press of a key. Here’s a guide to help you get started.
- F1: Paste the last command you executed character by character.
- F2: Paste the last command you executed up to the character you entered in the dialog box that shows up.
- F3: Repeat the previous command.
- F4: Delete the current prompt text up to the character you entered in the dialog box that shows up.
- F5: Paste commands most recently executed.
- F6: Paste a ^Z to the command prompt.
- F7: Displays a list of commands you previously executed.
- F8: Paste a cycle of commands you most recently executed.
- F9: Asks for the number of the command from the list showed when you pressed F7 to paste to the command prompt.
6. Selection Shortcuts
As the Command Prompt relies on the keyboard a great deal, there are a few nifty shortcuts that allow you to select as much text on the screen as you want.
- Ctrl + A: Highlights all text on the current line. Pressing this combo twice highlights all text on the command line screen.
- Shift + Up/Down Arrrow: Extends selection by one line up or down.
- Shift + Left/Right Arrow: Extends selection by one character to the left/right.
- Shift + Ctrl + Left/Right Arrow: Extends selection by one word to the left/right.
- Shift + Home: Extends selection to the beginning of a command. Pressing this combo twice includes the full path in the selection.
- Shift + End: Extends selection to the end of the current line.
- Ctrl + Shift + Home/End: Extends selection to the beginning or end of the screen.
- Shift + Page Up/Down: Extends selection by one page up or down.
7. Command History Navigation
Command prompt keeps a history of all the commands that you typed for the entire session. Here are some shortcuts that can save you some typing time.
- “Up” and “Down” arrows: Scroll backward and forwards through your command history
- “Right” arrow: Recreate the last executed command character by character.
- “Alt” + “F7:” Clear your command line history.
More Things You Can Do in the Command Prompt
8. Fix Your Internet Connection
Can’t connect to the Internet? Here are some commands that can help fix some of your connection woes:
- ipconfig /release: Release the current IP address
- ipconfig /renew: Request a new IP address
- ipconfig /flushdns: Resets the DNS Cache
DNS Cache Definition: A temporary storage containing the records of all recent visits to various websites and other domains. This makes it faster for the DNS client (your computer) to look up the IP address mapped to the website name you want to search.
9. Repair Windows System Files
If your built-in Windows applications stopped working as expected, you can key in sfc /scannow to have Windows scan for and replace any system files that have been corrupted. Reboot your computer after running the command to check if this command fixed your issues.
Watch the new Windows terminal in this video from Windows Developer:
Those are just some of command prompt hacks you can use to get things done. I hope you learned something today and see the humble command prompt in a new light.
Do you know of any more command prompt hacks to make your life much easier? Let us know in the comments below.