Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How does one clear all the entered commands in terminal? I am not talking about the clearcommand, which merely clears the screen. I want to clear all the commands that I have entered , so the window would completely clean. I've tried:

1. Quitting Terminal
2. Restarting my computer
3. The clear command

I am thinking there must be some way, because I've probably entered in about 50 million commands, and there are only 505 in my history.

share|improve this question
    
The command history is stored in a file, that's why it is persisting. I'm sorry I don't know where that file is in macs but on *nix systems it is usually in ~/ as a dot-file, named depending on what shell you're using. –  deed02392 Mar 31 '12 at 18:37
    
In bash, $HISTFILESIZE determines how many commands are kept, typically 500, with older ones being replaced by newer ones. That's why you don't see all commands you've entered. Cameron already said how to clean the history. –  lupincho Apr 1 '12 at 16:46
    
@deed02392, the name is similar on mac, e.g. for bash, it is ~/.bash_history –  Cameron Apr 1 '12 at 18:23

1 Answer 1

This should work (at least for bash):

$ history -c

Followed by quitting the terminal.

EDIT: Chris Page notes in the comments that quitting the terminal is unnecessary, as there is also a command to clear scrollback in most terminals. On Mac, e.g., this is under View > Clear Scrollback or ⌘K

share|improve this answer
    
Quitting Terminal or closing the terminal window/tab should be completely unnecessary to clear the shell command history. –  Chris Page Apr 1 '12 at 11:06
    
The part about quitting the terminal was because the poster wanted to know how to make the window "completely clean". Just clearing the history will only make the history go away, but you can still see what was executed during that login just by scrolling up in most terminal emulators. AFAIK, the only way to get rid of that information is to quit the terminal. –  Cameron Apr 1 '12 at 18:20
    
View > Clear Scrollback erases the scrollback text. –  Chris Page Apr 6 '12 at 2:50
    
@ChrisPage thanks, edited. –  Cameron Apr 6 '12 at 5:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.