i don't find the file .history in my home

med89med

New Member
Joined
Apr 4, 2021
Messages
5
Reaction score
3
Credits
62
Hello,

i was doing a homework that says to delete the history file : rm /home/myuser/.history
but i don't find this file in my home : error message while doing thiscommand : file not found. There is only the file .bash_history.
Im using fedora.


in ubuntu i don't see (.history nor .bash_history. ) (i use ls -a to display invisible files)
 


There is only the file .bash_history.

yep i'm on slackware and thats what i have as well . My last 3 (not including histroy command ) were :

498 cp persistence.dat /run/media/andrew/ventoy/
499 sync
500 su
501 history

and if i open .bash_history with say "kate" last entries are :

cp persistence.dat /run/media/andrew/ventoy/
sync
su


seems ok to me


assuming your in home directory whats the output of :


Code:
tail -n 5        .bash_history

then does that match last 5 using command

Code:
history
 
Ubuntu should have a .bash_history, if you've got a bash history. I don't think I've ever seen a '.history' file.

I'd ask the instructor for more information.
 
if you delete .bash_history , and you run history, you wil find all your history there. so there is no a directect relation beteween the command history and and the file .bash_history.

if you run history - c at this moment you will clear the concerned file . but this concened file i don't found him . can you help ?
 
well lets prove then that their is a relationship but bash holds the info until it exits.

First lets confirm .bash_history is your default store for bash commands:



Code:
bash-5.0$ echo $HISTFILE
this is mine :
bash-5.0$ echo $HISTFILE
/home/andrew/.bash_history
bash-5.0$

Now so as not to confuse work from one terminal and delete the file .bash_history




then on open terminal run :

Code:
kill -9 $$

then open terminal and run history command




(if you delete .bash_history , then play with commnds on terminal , .bash_history will be re-created AND store the last commands you played with)
 
Oh yeah... In my list of links to crib potential articles/keep as notes, I have this fairly recent gem.

 
G'day @med89med and welcome to linux.org :)

Just passing through, and maybe this will help.

No matter what Linux installed, .bash_history does not exist until you issue your first command from Terminal/console, whatever. It is only created then, and continues to grow, subject to scroll size limits you place or don't.

It defaults usually to 512 lines, and can be set to unlimited.

In any File Manager, you can go to Home and press Ctrl-h to show the hidden files and folders, and if your Preferences permits, set it to always how Hidden files and folders.

HTH

Wizard
 
G'day @med89med and welcome to linux.org :)

Just passing through, and maybe this will help.

No matter what Linux installed, .bash_history does not exist until you issue your first command from Terminal/console, whatever. It is only created then, and continues to grow, subject to scroll size limits you place or don't.

It defaults usually to 512 lines, and can be set to unlimited.

In any File Manager, you can go to Home and press Ctrl-h to show the hidden files and folders, and if your Preferences permits, set it to always how Hidden files and folders.

HTH

Wizard
Thanks, your answer and explanation helped me.
 
An easy way to do all of this...

To see Terminal history...run this command...
Code:
  history
1714368035626.png

I don't have much as I deleted it.
To delete it...
Run this command...
Code:
  history -c && history -w
1714368195658.png

It can't get any easier than that.
1714368286712.gif
 
Hello @sumathe,
Welcome to the Linux.org forum, enjoy!
 
It defaults usually to 512 lines, and can be set to unlimited.
Or it can get bugged which happened to me about a year ago when something (unclear what) kept rewriting the file even when I wasn't using the terminal at all which led to .bash_history to grow fast in size becoming many megabytes. On top of that every single issued command created a separate file named .bash_history_tmp_[random-number] and at some point the only thing you could see in /home were these temporary files. The command to disable history never worked, so the only solution for me was to manually delete all content from the original .bash_history and then make the file immutable which fixed both problems. During all the 9 years with linux I've never needed that history file anyway.
 
if you delete .bash_history , and you run history, you wil find all your history there. so there is no a directect relation beteween the command history and and the file .bash_history.

That's only true until you reboot. It will cache the history file and the commands since the last reboot.
But if there is no history file, and you reboot, it'll only cache the current session commands.
Of course it will automatically create a new file.
 
On top of that every single issued command created a separate file named .bash_history_tmp_[random-number] and at some point the only thing you could see in /home were these temporary files.
This propagation of files in /home/<user>/. has arisen a few times on machines here. The solution I adopted was to run a command like the following in ~/.bash_logout, so that every time the user logged out, those files, which were invariably empty, were removed:
Code:
find /home/<user>/ -maxdepth 1 -name ".bash_history-*.tmp" -exec rm -rf {} \;
A command like that could go in .profile, or .bash_profile, or a cron job or a systemd unit with timer or a scripted executable to remove the useless files. I haven't investigated their origin, but removal hasn't raised any issues.
 
OP hasn't been seen for 3 years...maybe got an answer.
1714538203952.gif
 

Staff online


Top