The fastest way to clear your terminal input

If you've typed a long command and want to start over without running it, press Ctrl+U on Linux or Mac, or Ctrl+A followed by Delete on Windows PowerShell. This deletes everything you've typed on the current line without executing it. The cursor stays at the prompt, ready for a new command.

This is different from clearing the entire terminal window — which shows all your past commands and their output. Clearing your input means erasing only what you're currently typing, before you press Enter. The distinction matters because one action removes text you haven't run yet, while the other hides commands that have already executed.

Key Takeaways

  • Press Ctrl+U on Mac or Linux to delete everything typed on the current line in one keystroke.
  • On Windows PowerShell, press Ctrl+A then Delete to clear your current input, since PowerShell does not recognize Ctrl+U.
  • These shortcuts work at the command prompt and do not run any command or add anything to your history.
  • If you want to clear the entire terminal window instead, use clear on Mac and Linux or cls on Windows PowerShell.
  • Clearing input is especially useful when you accidentally start typing a password or sensitive information at the prompt.

Why you might need to clear your input

You typed a long command and realized halfway through it's wrong. Running it would cause an error or do something you didn't intend. Rather than let it execute, you want to erase it and start fresh. This happens often when you're building a complex command with multiple options and flags — one mistake early on means the whole thing needs to go.

Another common reason: you started typing a password or sensitive information at the prompt by accident, and you want to remove it before pressing Enter. Clearing the line keeps that text from being stored in your command history. This is a security concern because anyone with access to your terminal history could see that information.

A third scenario is when you paste a command from somewhere and realize partway through that it's not what you wanted. Instead of watching it run and then dealing with the consequences, you can clear it when ready and try again.

Clearing input on Mac and Linux

Press Ctrl+U. This deletes everything from the cursor position back to the start of the line. If your cursor is at the end (which it usually is while you're typing), this clears the entire command you've entered. The prompt reappears when ready, and you can begin typing a new command.

If you want to delete only from the cursor forward to the end of the line, press Ctrl+K instead. This is useful if you've moved your cursor backward using the left arrow key and want to erase only the rest of the command without touching what came before. For example, if you typed rm -rf /home/user/documents/file.txt and moved back to fix the filename, Ctrl+K would delete only the filename portion.

To delete a single word backward (the word your cursor is in or just before), press Ctrl+W. This is faster than holding Backspace if you mistyped one word in a long command. Each press of Ctrl+W removes one word, so you can use it multiple times to back up further.

Clearing input on Windows PowerShell

Press Ctrl+A to select all the text you've typed on the current line, then press Delete or Backspace to remove it. The entire command disappears and the cursor returns to the prompt. You'll see the text highlight briefly before it vanishes.

Windows PowerShell does not recognize Ctrl+U the way Linux and Mac terminals do. If you're switching between systems, Ctrl+A followed by Delete works on all three, though it requires two key presses instead of one. Some people prefer this method for consistency, even on Mac and Linux, since muscle memory matters when you move between computers.

Clearing the entire terminal window instead

If you want to erase all the commands and output you've already run — not just what you're currently typing — use a different command. On Mac and Linux, type clear and press Enter. On Windows PowerShell, type cls and press Enter. Both commands scroll all previous commands and their output off the screen, giving you a blank terminal to work with.

This is useful when your terminal has accumulated so much output that it's hard to read, or when you want a fresh visual start before beginning a new task. Your command history is still saved in the system; you're only clearing what's visible on screen. You can still scroll up in most terminal applications to see what was there before.

What happens to your command history

When you clear your current input with Ctrl+U or Ctrl+A + Delete, the command never runs, so it is not added to your history. This is why clearing input is useful for sensitive information — the text you erased is not stored anywhere. If you later press the up arrow key to scroll through previous commands, you won't see the command you cleared.

When you use clear or cls to clear the terminal window, your history remains intact. You can still scroll up or use the up arrow key to see previous commands. Clearing the window only hides what's on screen; it does not delete the record of what you've run. The commands are still in your shell history file, which is usually stored in your home directory.

Frequently Asked Questions

What if Ctrl+U doesn't work on my Mac?

Check your terminal settings. Some terminal applications or shells remap keyboard shortcuts. Try Ctrl+A to move to the start of the line, then Shift+End to select to the end, then Delete. If that doesn't work, your terminal may have custom keybindings — check the Preferences or Settings menu in your terminal process.

Can I undo clearing my input?

Once you press the key combination, the text is gone and cannot be recovered. There is no undo for cleared input. If you're unsure about a command, it's safer to press Ctrl+C to cancel it after you run it, rather than clear it beforehand.

Is there a way to clear input on all three systems with the same shortcut?

Not one single keystroke, but Ctrl+A followed by Delete works on Windows, Mac, and Linux. It takes two key presses instead of one, but it's consistent across platforms if you switch between them often.

What's the difference between clearing input and canceling a running command?

Clearing input removes what you've typed before you press Enter. Canceling a running command stops a command that has already started executing — you do that by pressing Ctrl+C. They solve different problems at different stages of the process.