bash command "history -c" not working

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read this

bash command "history -c" not working

Postby Herbivore on Wed Feb 10, 2010 11:39 pm

Recently installed Linux Mint 8 Helena - Main Edition. Unlike in previous Mints, "history -c" does not clear bash history and I can not find the usual /.bash or /.history in home folder. After entering history -c in a terminal and trying to view history with the up arrow, there is no history. But when a new terminal opened, the up arrow again cycles through the command history. Typing sudo history -c produces

sudo: history: command not found

Any assistance appreciated.
Herbivore
Level 2
Level 2
 
Posts: 64
Joined: Mon Jun 11, 2007 6:59 pm

Linux Mint is funded by ads and donations.
 

Re: bash command "history -c" not working

Postby pompom on Thu Feb 11, 2010 3:08 am

Welcome to Linux Mint!

Maybe you are looking for the not correcto mundo file? It is quite possible that during the upgrade you were also upgraded to the latest bash, which may explain things. Neither one of these "commands" worked for me and I am using bash 4.0.33, because I am always running another bash instance one keystroke away at startup. Check if you have a history file

Code: Select all
locate history | grep bash


this returns /home/pompom/.bash_history and /usr/share/bashdb/command/history.sh.

If you want to clear the file, the Linux way of doing things would be

Code: Select all
> .bash_history


Cheers,

pompom
"This is Linux. It gives you cute mascot and enough rope to hang yourself." --- Miquel van Smoorenburg
pompom
Level 4
Level 4
 
Posts: 218
Joined: Mon Dec 14, 2009 2:27 am
Location: Komandorsky Archipelago, Kamchatka Peninsula

Re: bash command "history -c" not working

Postby Herbivore on Thu Feb 11, 2010 5:21 am

Interesting... With hidden files shown, Nautilus does not show /.bash_history even though when I ran your grep line I received same result as you:

Code: Select all
tmr@tmr-mint8 ~ $ locate history | grep bash
/home/tmr/.bash_history


Likewise, bash version 4.0.33.

But the search did not find any bash history db in /usr or anywhere else.

I looked up the command character ">" and found that it is called a redirection notation. Beyond me. And copying the command you gave, " > .bash_history", into the terminal produced no effect:
Code: Select all
tmr@tmr-mint8 / $ locate history | grep bash
/home/tmr/.bash_history
tmr@tmr-mint8 / $ > .bash_history
bash: .bash_history: Permission denied
tmr@tmr-mint8 / $ sudo > .bash_history
bash: .bash_history: Permission denied

Tried su and got:
Code: Select all
tmr-mint8 / # > .bash_history
tmr-mint8 / #

which also did not work, bash history still there.

So, if it is not too much trouble to hand walk this newbie through the process of clearing bash history, I would be grateful.
Herbivore
Level 2
Level 2
 
Posts: 64
Joined: Mon Jun 11, 2007 6:59 pm

Re: bash command "history -c" not working

Postby pompom on Fri Feb 12, 2010 1:34 am

Hi,

There's something amiss with your user account. Check under Administration -> Users and Groups and make sure everything is checked. For one thing, you should not need to become superuser in order to access BASH history file. You may have to 'chown' and/or 'chmod' to get the herring swimmin' again

Code: Select all
set | less


When you scroll down, you should see

HISTFILE=/home/pompom/.bash_history
HISTFILESIZE=500
HISTSIZE=500
HOME=/home/pompom

Code: Select all
ls -l ~/.bash_history


-rw------- 1 pompom pompom 252 2010-02-12 00:12 /home/pompom/.bash_history

The redirection operator with "nothing" prepended will zero out just about any file. Viz.

Code: Select all
> .bash_history


ls -l ~/.bash_history

-rw------- 1 pompom pompom 0 2010-02-12 00:16 /home/pompom/.bash_history

To prevent BASH from writing to .bash_history upon exit

Code: Select all
unset HISTFILE


After exit and running several commands followed by another exit, it still showing a zero byte file:

-rw------- 1 pompom pompom 0 2010-02-12 00:32 .bash_history

Cheers,

pompom
"This is Linux. It gives you cute mascot and enough rope to hang yourself." --- Miquel van Smoorenburg
pompom
Level 4
Level 4
 
Posts: 218
Joined: Mon Dec 14, 2009 2:27 am
Location: Komandorsky Archipelago, Kamchatka Peninsula


Return to Newbie Questions

Who is online

Users browsing this forum: Bing [Bot], Toimu and 31 guests