How to delete history for a particular user

Hi All,

Whenever I log in to my terminal and execute some cmds and then I type "history", I get the list of all the commands that I have executed.

I want to know where is the history been stored (any path location ?)
Secondly,if I want to delete the history or some part of the history, can I do it ? If yes, how?

Thanks and Regards,
Shubhranshu.

If your shell is bash, execute 'man builtins'. Search for 'history'.

Generally you dont have permission for execute this operations, only a Superuser. Search your ./bash_history if you have bash, and delete them if you can.

In KSH, the the location of the history file is based on the HISTFILE variable. Usually, you set this variable to your home directory.
ie. HISTFILE=~/.history

default for ksh ist .sh_history and for bash .bash_history in your home directory

logout, log in and use ">.sh_history" for example

Thanks for the answers...

I got the file .. mine is in bash so I got the .bash_history file
I removed the contents of the file.

hyper20:~ 22> cat .bash_history
hyper20:~ 23>

but then when I agian type the command history :- it is still showing the history of commands executed :slight_smile:

==========
hyper20:~ 23> history
1 1:53 showbl
2 2:05 cd
3 2:05 while [1]
4 2:10 while {1}
5 2:10 while [ 1 ]
6 2:13 pwd
7 2:13 cd
8 2:14 ls -a
9 2:14 vi .bash_history
10 2:14 ll .bash_history
11 2:16 env | grep HISTFILE
12 2:16 env
13 2:17 ls -a
14 2:18 vi .bash_history
15 2:18 history
16 2:18 vi .bash_
17 2:18 vi .bash_history
18 2:19 vi .bashrc
19 2:19 vi .viminfo
20 2:19 history
21 2:19 ll -a
22 2:19 cat .bash_history
23 2:20 history

Could you please help me in this as to how still I am getting the history ?

Thanks.

Thanks for the answer...

I got the file .. mine is in bash so I got the .bash_history file

I removed the contents of the file.

hyper20:~ 22> cat .bash_history
hyper20:~ 23>

but then when I agian type the command history :- it is still showing the history of commands executed

==========

hyper20:~ 23> history
1 1:53 showbl
2 2:05 cd
3 2:05 while [1]
4 2:10 while {1}
5 2:10 while [ 1 ]
6 2:13 pwd
7 2:13 cd
8 2:14 ls -a
9 2:14 vi .bash_history
10 2:14 ll .bash_history
11 2:16 env | grep HISTFILE
12 2:16 env
13 2:17 ls -a
14 2:18 vi .bash_history
15 2:18 history
16 2:18 vi .bash_
17 2:18 vi .bash_history
18 2:19 vi .bashrc
19 2:19 vi .viminfo
20 2:19 history
21 2:19 ll -a
22 2:19 cat .bash_history
23 2:20 history

Could you please help me in this as to how still I am getting the history ?

Thanks.

the history resides in cache unless you log out
then it is written to .bash_history

so clean the history, logout and login, then the history should be empty, just the command to delete the history and an exit should be there

Obvious question:

why?

Hi Neelpert1,

I am sorry I did not understand what you wanted to know by "why ?"

Could you please expand your question?

Thanks.