[SOLVED] Deleting particular date's history command.
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: RHEL, CentOS, Debian, Oracle Solaris 10
Posts: 1,420
Rep:
Deleting particular date's history command.
Friends,
I have a problem to discuss with you.
I want to delete particular date's history commands and when I run back the history command it should not show the delted history command. How to do this?
On a standard installation the history commands doesn't show date information. Did you use something like HISTTIMEFORMAT to include that info in the command history? If so, then you could use sed/awk to do what you want. If not, then you can edit the .bash_history file for your user manually. If you could specify a bit more to why and what you want to remove from your history file and what OS you're using we might be able to provide more dedicated help.
Other users accessing the same machine but with a different user id don't have access to your history file unless they have the permissions granted by either you or root. You could always copy your history file to your local computer and clear out the history entirely before logging out. And why are you afraid that others might see what commands you use? It's all common knowledge and what you know can be found on the internet pretty easy. I can only hope you're not referring to the root user being shared with multiple users. Root usage should be limited to a strict minimum.
Then you either ask to be granted the permissions necessary or stop trying to bypass security. It's there for a reason you know. If you don't want others, who have been granted root access to see what commands you run, then I can only assume that you're trying to hide something from them. Either way, in my personal opinion, you're not working in a professional way, no insult intended.
Distribution: RHEL, CentOS, Debian, Oracle Solaris 10
Posts: 1,420
Original Poster
Rep:
Yes I want to hide some of the things and I'm working in a professional way. There are some of the things which need to hide from them. And my senior told me to do this, that's why I'm doing this, otherwise there is no need to do this.
So please help me.
Ok, I used history -d 2003 to delete the line no. 2003 but when I again run history command it shows the command used to delete the previous command i.e., it shows history -d 2003. Now I want that it should no happen.
Now you've got me confused. First you state you don't have permission to delete history of commands and now you did delete one? If you do have permission to do it, then go the manual way or use what I indicated in post #2. Still not convinced though that this is the professional thing to do but hey, it's your history.
Distribution: RHEL, CentOS, Debian, Oracle Solaris 10
Posts: 1,420
Original Poster
Rep:
Ofcourse I don't have permission to delete history commands but some of the traces should not be left behind, that's why we have to do something so that our super senior guy should not be able to see what we have done.
Ok, so deleting the line from .bash_history file do not show what we have deleted when we again run history command?
I don't feel good at all with the fact that you're hiding stuff from your superiors for whatever reason you might have. So you're on your own for as far as I'm concerned.
Distribution: RHEL, CentOS, Debian, Oracle Solaris 10
Posts: 1,420
Original Poster
Rep:
Eric,
There is no need to feel bad about this. Actually my senior told me to hide this from super-senior, that's why I have to do this. This is somehing sometimes which I and my colleague have to do this. There is no big issue for this my friend.
Last edited by Satyaveer Arya; 12-06-2011 at 04:37 AM.
Sorry - I didn't mention the reason for closure. If you're trying
to "cover your tracks" on a machine against the owners intended usage
you're in breach of our rules, and as such your thread is unacceptable.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.