Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

How to delete logs & history of bash?

How to del?
[Image: Crkh464s8.png]
Step 1 to learn how to do things on linux:
Learn how to google.

http://askubuntu.com/questions/191999/ho...completely
Bash stores commands in memory so you can adjust how it writes to the history file depending on how you like. It could be after each command or upon exit which is the default.

It is stored into ~/.bash_history so you just need to remove that file. But by default it will create a new one and dump that session into it.

If you want it to be stuck and not write anything to that file or keep any history you can try to create the file and set special flags on it which makes it immune to any changes, even by root.

PHP Code

<?php 
rm 
~/.bash_history # to remove the history file
touch ~/.bash_history # to create it again 
chattr +i ~/.bash_history # immune to any changes. It should stay empty that way 

I hope I've helped.
(Feb 24, 2017 08:51 PM)SuckySucky Wrote:  Bash stores commands in memory so you can adjust how it writes to the history file depending on how you like. It could be after each command or upon exit which is the default.

It is stored into ~/.bash_history so you just need to remove that file. But by default it will create a new one and dump that session into it.

If you want it to be stuck and not write anything to that file or keep any history you can try to create the file and set special flags on it which makes it immune to any changes, even by root.

PHP Code

<?php 
rm 
~/.bash_history # to remove the history file
touch ~/.bash_history # to create it again 
chattr +i ~/.bash_history # immune to any changes. It should stay empty that way 

I hope I've helped.
Helped clear but its still there if a forensics test is run.
Btw did not perm keep it clear.
https://cdn.pbrd.co/images/Crz51mrDm.png
(Feb 24, 2017 08:58 PM)Techmech Wrote:  Helped clear but its still there if a forensics test is run.
Btw did not perm keep it clear.
https://cdn.pbrd.co/images/Crz51mrDm.png

Run a few test commands;

Then close Bash and open it up again.. Then run this command:

PHP Code

<?php 
cat 
~/.bash_history 

And see if it is empty or not. I kinda think that what "history" shows you is the history that is in memory but not what has been actually written. I also just mentioned a very dirty way to disable it as there are better ways most likely.


You can permanently disable it this way:

PHP Code

<?php 
echo 'set +o history' >> ~/.bashrc # Bash for this user
. ~/.bashrc # to apply it immidiately on this session
echo 'set +o history' >> /etc/profile # System wide for bash 
"One annoying side-effect is that the history entries has a copy in the memory and it will flush back to the file when you log out."

Read the link I posted earlier. Google is your friend.
(Feb 24, 2017 09:47 PM)captainspalding Wrote:  "One annoying side-effect is that the history entries has a copy in the memory and it will flush back to the file when you log out."

Read the link I posted earlier. Google is your friend.

Not if you disable the history all together as I mentioned at the bottom of my post. That way there is no history to be found at all as you've told bash to disable it.

[Image: DTFrbOX.png]

And example of what happens if you run

rm ~/.bash_history && set +o history && history -c
(Feb 24, 2017 10:06 PM)SuckySucky Wrote:  Not if you disable the history all together as I mentioned at the bottom of my post. That way there is no history to be found at all as you've told bash to disable it.

[Image: DTFrbOX.png]

And example of what happens if you run

rm ~/.bash_history && set +o history && history -c
You can disable it completely, but you're probably going to want to see the previously run command etc. for a short period of time. I run a cron job to delete my bash history, but I back it up to my server with tar and rsync.
XMPP: pm me
Thanks for the info. Worked for me and deleted bash history.
unset HISTFILE when you login, and it won't be saved

or history -c to delete what you've previously typed

or nano ~/.bash_history and CTRL-K every line
[Image: RIP7FkV.gif]


Possibly Related Threads...
Thread / Author Replies Views Last Post
by Tex.Apr 21, 2016 02:25 PM 3 95 Apr 21, 2016 02:25 PM
Last Post: FreakyFreak
by raxeJul 20, 2012 05:31 AM 2 79 Jul 20, 2012 05:31 AM
Last Post: raxe
by Anonymous.7654Jul 23, 2011 11:57 AM 5 346 Jul 23, 2011 11:57 AM
Last Post: Amzo