bash command "history -c" not working

Quick to answer questions about finding your way around Linux Mint as a new user.
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. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
Herbivore
Level 2
Level 2
Posts: 66
Joined: Mon Jun 11, 2007 6:59 pm

bash command "history -c" not working

Post by Herbivore »

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.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
pompom

Re: bash command "history -c" not working

Post by pompom »

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
Herbivore
Level 2
Level 2
Posts: 66
Joined: Mon Jun 11, 2007 6:59 pm

Re: bash command "history -c" not working

Post by Herbivore »

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.
pompom

Re: bash command "history -c" not working

Post by pompom »

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
Locked

Return to “Beginner Questions”