Windows command line clear command

The clear command in Linux is used to clear the terminal’s screen.

You can also use the clear command in a Windows PowerShell where it is an alias of the Clear-Host command, that does pretty match the same – removes all text from the current display, including commands and output that might have accumulated.

But if you try to execute the clear command in a Windows command-line prompt (CMD), expecting it to clear the screen, you will get an error as follows:

‘clear’ is not recognized as an internal or external command,
operable program or batch file.

Below you will find how to clear the command prompt in Windows.

To clear the screen in the Windows command-line prompt (CMD), use the cls command:

C:\> cls

Was it useful? Share this post with the world!

In the Microsoft Windows command prompt (cmd) you can use cls command to clear screen of cmd. This equal to clear Command on Unix Like Operating Systems.

cls

Clear Screen in CMD
windows cmd clear screen

Keyboard Shortcut to cls Command

Well, I do not think there is a keyboard shortcut to cls command(clear cmd) in windows, at least not by default. But that as for my knowledge (I even search in the Google).
Anyway, If any one of you know the shortcut just drop me an email message @ [email protected], SO I can update this tutorial.

Command Line Commands – CLI Tutorial

The Windows command line is one of the most powerful utilities on a Windows PC. With it, you can interact with the OS directly and do a lot of things not available in the graphical user interface (GUI).

In this article, I’ll show you 40 commands you can use on the Windows command line that can boost your confidence as a Windows user.

N.B.: You have to be careful while using the commands I’ll show you. This is because some commands can have a lasting negative or positive effect on your Windows PC until you reset it.

In addition, some of these commands require you to open the command prompt as an admin.
ss5-1

powershell start cmd -v runAs – Run the Command Prompt as an Administrator

Entering this command opens another command prompt window as an administrator:
ss1-1

driverquery – Lists All Installed Drivers

It is important to have access to all drivers because they often cause problems.

That’s what this command does – it shows you even the drivers you won’t find in the device manager.
ss2-1

chdir or cd – Changes the Current Working Directory to the Specified Directory

ss3-1

systeminfo – Shows Your PC’s Details

If you want to see more detailed information about your system you won’t see in the GUI, this is the command for you.
ss4-1

set – Shows your PC’s Environment Variables

ss5-2

prompt – Changes the Default Text Shown before Entering Commands

By default, the command prompt shows the C drive path to your user account.

You can use the prompt command to change that default text with the syntax prompt prompt_name $G:
ss6-1

N.B: If you don’t append $G to the command, you won’t get the greater than symbol in front of the text.

clip – Copies an Item to the Clipboard

For example, dir | clip copies all the content of the present working directory to the clipboard.
ss7

You can type clip /? and hit ENTER to see how to use it.

assoc – Lists Programs and the Extensions They are Associated With

ss8

title – Changes the Command Prompt Window Title Using the Format title window-title-name

ss9

fc – Compares Two Similar Files

If you are a programmer or writer and you want to quickly see what differs between two files, you can enter this command and then the full path to the two files. For example fc “file-1-path” “file-2-path”.
ss10

cipher – Wipes Free Space and Encrypts Data

On a PC, deleted files remain accessible to you and other users. So, technically, they are not deleted under the hood.

You can use the cipher command to wipe the drive clean and encrypt such files.
ss11

netstat -an – Shows Open Ports, their IP Addresses and States

ss12

ping – Shows a Website IP Address, Lets you Know How Long it Takes to Transmit Data and a Get Response

ss13

color – Changes the Text Color of the Command Prompt

Enter color attr to see the colors you can change to:
ss14

Entering color 2 changes the color of the terminal to green:
ss15

for /f "skip=9 tokens=1,2 delims=:" %i in ('netsh wlan show profiles') do @echo %j | findstr -i -v echo | netsh wlan show profiles %j key=clear – Shows All Wi-Fi Passwords

ss16

ipconfig – Shows Information about PC IP Addresses and Connections

ss17

This command also has extensions such as ipconfig /release, ipconfig /renew, and ipconfig /flushdns which you can use to troubleshoot issues with internet connections.

sfc – System File Checker

This command scans your computer for corrupt files and repairs them. The extension of the command you can use to run a scan is /scannow.
ss18

powercfg – Controls Configurable Power Settings

You can use this command with its several extensions to show information about the power state of your PC.

You can enter powercfg help to show those extensions.
ss19

For example, you can use powercfg /energy to generate a battery health report.
ss20

The powercfg /energy command will generate an HTML file containing the report. You can find the HTML file in C:\Windows\system32\energy-report.html.

dir – Lists Items in a Directory

ss21

del – Deletes a File

ss22

attrib +h +s +r folder_name – Hides a Folder

You can hide a folder right from the command line by typing in attrib +h +s +r folder_name and then pressing ENTER.

To show the folder again, execute the command – attrib -h -s -r folder_name.
ss23

start website-address – Logs on to a Website from the Command Line

ss24
ss25

tree – Shows the Tree of the Current Directory or Specified Drive

ss26

ver – Shows the Version of the OS

ss27

tasklist – Shows Open Programs

You can do the same thing you do with the task manager with this command:
ss28
The next command shows you how to close an open task.

taskkill – Terminates a Running Task

To kill a task, run taskkill /IM "task.exe" /F. For example, taskkill /IM "chrome.exe" /F:
ss29

date – Shows and Changes the Current Date

ss30

time – Shows and Changes the Current Time

ss31

vol – Shows the Serial Number and Label Info of the Current Drive

ss32

dism – Runs the Deployment Image Service Management Tool

ss33

CTRL + C – Stops the Execution of a Command

-help – Provides a Guide to other Commands

For example, powercfg -help shows how to use the powercfg command
ss34

echo – Shows Custom Messages or Messages from a Script or File

ss35

You can also use the echo command to create a file with this syntax echo file-content > filename.extension.
ss36

mkdir – Creates a Folder

ss37

rmdir – Deletes a Folder

ss38

N.B.: The folder must be empty for this command to work.

more – Shows More Information or the Content of a File

ss39

move – Moves a File or Folder to a Specified Folder

ss40

ren – Renames a File with the Syntax ren filename.extension new-name.extension

ss41-1

cls – Clears the Command Line

In case you enter several commands and the command line gets clogged up, you can use cls to clear all entries and their outputs.
cls

exit – Closes the Command Line

shutdown – Shuts down, Restarts, Hibernates, Sleeps the Computer

You can shut down, restart, hibernate, and sleep your PC from the command line.

Enter shutdown in the command line so you can see the extensions you can use to perform the actions. For example, shutdown /r will restart your computer.
ss42

Conclusion

This article showed you several “unknown-to-many” commands you can use to get access to hidden functionalities on your Windows PC.

Again, you should be careful while working with these commands because they can have a lasting effect on your OS.

If you find the commands helpful, share the article with your friends and family.

In case you know another useful command I did not list, tell me about it on Twitter. I will add it and mention you as the source.



Learn to code for free. freeCodeCamp’s open source curriculum has helped more than 40,000 people get jobs as developers. Get started

3

Problem :

When writing long commands, sometimes I want to clear the line in one shot.

I know how to do it in Windows : Hold Shift, Home key, then delete. However this doesn’t work in command prompt. How can I do this?

  • windows
  • command-line

Improve this question

edited Jul 6, 2015 at 20:24

Cher

asked Jul 6, 2015 at 20:19

Cher's user avatar

CherCher

2,79910 gold badges37 silver badges64 bronze badges

0

Add a comment
 | 

1 Answer

Sorted by:

Reset to default

10

Hit Esc to clear the current command.

Improve this answer

answered Jul 6, 2015 at 20:29

glenn jackman's user avatar

glenn jackmanglenn jackman

240k38 gold badges222 silver badges354 bronze badges

Add a comment
 | 

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

Sign up or log in

Sign up using Google

Sign up using Facebook

Sign up using Email and Password

Post as a guest

Name

Email

Required, but never shown

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you’re looking for? Browse other questions tagged

  • windows
  • command-line

or ask your own question.

How can I clear the current line in the command prompt? (I’m using Windows 7.)

Too often, I enter a command, execute it, get many lines of output, then wish to enter another command. But before entering the second command, I press the up arrow key to review the first command, then I find I have to hold backspace for 30-or so characters. (I can’t just press down again to get an empty line. Nor can I get it by pressing up again.)

essential's user avatar

asked Mar 5, 2012 at 18:43

JellicleCat's user avatar

2

The Escape (Esc) key will clear the input line.

In addition, pressing Ctrl+C will move the cursor to a new, blank line. This may be helpful as the input you just reviewed remains visible while you type the new command.

answered Mar 5, 2012 at 18:45

Myrddin Emrys's user avatar

Myrddin EmrysMyrddin Emrys

2,3813 gold badges21 silver badges29 bronze badges

12

Aside from the two that Myyrddin covered — Esc and Ctrl+C — there are also two more shortcuts related to clearing the current input in CMD.

Ctrl+Home will clear all characters in the input before the cursor (equivalent to Ctrl+U in Bash)

Ctrl+End will clear all characters in the input after the cursor (equivalent to Bash’s Ctrl+K)

Both are fairly useful and, once internalised and gotten used to, could speed up editing in CMD by quite a bit.

answered Nov 22, 2016 at 23:39

Hashim Aziz's user avatar

Hashim AzizHashim Aziz

12.1k35 gold badges99 silver badges167 bronze badges

5

You must log in to answer this question.

Not the answer you’re looking for? Browse other questions tagged

.

  • Windows com stopcode что это
  • Windows cannot be installed to this disk selected disk is gpt partition style
  • Windows com stopcode page fault in nonpaged area
  • Windows cannot be installed to disk the selected disk is of the gpt partition style
  • Windows cmd output to file