I was curious if there is a way to clear the terminal buffer/output through some keyboard shortcut. I am using Ubuntu. I am aware that

Ctrl + L

clears the terminal, but you can still scroll back to see the old text. I am looking for something similar to what


command does. On Mac

apple + k

seems to do the trick.

  • 1
    You can type "clear".
    – Darren
    Commented Feb 22, 2017 at 19:14
  • Thanks for mac command :D, i was looking for it Commented Feb 3, 2022 at 7:01

9 Answers 9


In gnome terminal, you can edit the keyboard shortcuts with Edit -> Reset Shortcuts... You can then map the command "Reset and Clear", which seems to do what you're looking for.

Alternatively, you can limit the scrollback history to a small number (say 0) and Ctrl+L will be closer to what you are looking for.

  • 3
    This may have changed in newer versions of gnome and the gnome terminal. For me it's Edit -> Preferences -> Shortcuts (I'm using GNOME Terminal v3.16.2)
    – user486673
    Commented Aug 21, 2015 at 13:43
  • 4
    "Reset and Clear" was what I was looking for, except that it failed to preserve the prompt. Following immediately with Ctrl+L restores the prompt. So with Reset and Clear bound to Ctrl+K, I can hit Ctrl+K, Ctrl+L to clear the scrollback and leave me with a ready prompt. Commented Jun 7, 2017 at 11:45
  • Unfortunately while you can bind Reset and Clear to Ctrl+K, I can't find a way to unbind "clear to the beginning of the line", so now Ctrl+K deletes the shell prompt too. Hmmm.
    – Timmmm
    Commented Jan 4, 2023 at 15:00
  • Actually scratch that, the Reset and Clear action itself destroys the prompt, so this isn't really the same as Cmd+K on Mac.
    – Timmmm
    Commented Jan 4, 2023 at 15:01
  • CTRL+u clears from cursor to beginning of line

  • CTRL+k clears from cursor to end of line

  • CTRL+d clears one character to the right of the cursor

  • Esc+Backspace clears one word to the left of the cursor

  • Esc+d clears one word to the right of the cursor

  • Alt+left/right jumps to the beginning of the previous/next word

  • Ctr+a jumps to start of line

  • Ctr+e jumps to end of line

To clear the entire screen add the following alias to your ~/.bashrc file:

alias cls="echo -ne '\033c'"

Now, in a new terminal typing cls will clear everything including the scroll buffer. It works much faster than reset since it does not reset anything.

In fact reset is only needed when you want to fix a broken terminal, e.g. after running cat on a binary file.

If you are on OSX, then Command ()+k will clear the terminal (also works in the chrome devtools console).

  • And how would I add a shortcut to do this using without typing out cls? Commented Jul 5, 2014 at 6:01
  • 2
    @FloatingRock: this would depend on your desktop environment and possibly your terminal, if the terminal has no way of attaching a command to a shortcut, then your only chance is to set a system-global shortcut which is DE-dependent. For example, in XFCE, that would be Settings > Keyboard > Shortcuts, don't remember for other shells.
    – ccpizza
    Commented Jul 6, 2014 at 15:19
  • 2
    I've been looking for something like this for months.. Commented Dec 2, 2014 at 14:36
  • 1
    The program underneath most of these shortcuts is readline. A standard in a lot of Repl environments.
    – Niels Bom
    Commented Oct 24, 2022 at 6:20

In Ubuntu 18.4 Ctrl+Alt+ L will do the trick.

  • 2
    VLQ reviewers: I think here a short answer is pretty okay.
    – peterh
    Commented Mar 16, 2020 at 2:09

Ctrl+L redraws the terminal; it doesn't clear it. If you're in a full-screen app like less or vim, the Ctrl-L command is what you use to redraw a corrupted screen. In vim with color syntax highlighting, for example, you can use ctrl_l to update the colors if you scroll a long distance and vim gets confused by matching quotes or brackets or similar.

Just for reference if someone searches and finds this... If you need to clear the scroll-back buffer, either set your buffer to 0 lines or close the window and reopen it. Or "while true; do print; done" and then interrupt with ctrl+c when you've output enough lines to blow the buffer. The scroll buffer is application dependent, so while the given solution works for Gnome terminal, it won't work for really any other terminal device.

  • This "blow the buffer" wont work for unlimited scrollback mode.
    – Ruslan
    Commented Oct 8, 2018 at 14:40

I use Konsole. I've always used Ctrl+Shift+X in the past to clear everything, including the scrollback. There is a new and better way now: Ctrl+Shift+K and Googling "konsole keyboard shortcuts clear history" doesn't get you there very easily, but it gets you here.


on Ubuntu 20.04 in terminal, when you want to achieve the same as by clicking in menu on Advanced > 'Reset and Clear':

via shortcut, you can use: Ctrl+Shift+L

  • Welcome to Super User! Before answering an old question having an accepted answer (look for green ✓) as well as other answers ensure your answer adds something new or is otherwise helpful in relation to them. Here is a guide on How to Answer. There is also tour for the site tour, and help center for the help center. Commented Apr 21, 2021 at 10:18
  • Which terminal emulator does this work in? Commented Feb 22, 2023 at 16:33

Use one of these (depending on whether vi-mode is OFF/ON:

bind '"\C-c":clear-screen'
bind -m vi-command '"\C-c":clear-screen'

If you are on Ubuntu, open your terminal and go to Preferences - Shortcuts. There, find "Reset and Clear" option. Click that and type your shortcut as what you want. This works on my Ubuntu 20.04.


Based on Trevor Dixon's comment on the accepted answer, it's possible to (easily) make a shortcut that maps Ctrl+k to what you want.

  1. Install AutoKey
  2. Open AutoKey and create a new script.
  3. In the script, add gnome-terminal-server.Gnome-terminal to the Window Filter.
  4. In the script, set the Hotkey to <ctrl>+k.
  5. In the script body, add the following:
  6. Save the script.
  7. In the Terminal app, map Preferences > Shortcuts > Reset and Clear to Ctrl+Shift+k.

Now Ctrl+k in the Terminal app should clear all scrollback and show the prompt. In my experience this exactly matches what Cmd+k does in macOS.

You must log in to answer this question.