How to remove / clean trace and history on linux

Remove login trace :

CommandLogfileDescription
last /var/log/wtmp Lists successful login/logout history
lastb /var/log/btmp Shows the bad login attempts
lastlog /var/log/lastlog Shows the most recent login
echo > /var/log/wtmp
echo > /var/log/btmp
echo > /var/log/lastlog

Remove history :

Clear Bash history completely :
Type the following command to clear all your Bash history:
history -cw
-c Clear the history list
-w Write out the current history to the history file

Remove a certain line from Bash history :
Type the following command to remove a certain line (e.g. 352) from the Bash history file:
history -dw 352
-d Delete specified line from the history

Clear current session history :
Type the following command to clear the Bash history of the current session only:
history -r

Execute a command without saving it in the Bash history :
command
Put a space in front of your command and it won’t be saved in the Bash history.

Don’t save commands in Bash history for current session :
unset HISTFILE
Unsetting HISTFILE will cause any commands that you have executed in the current shell session not to be written in your bash_history file upon logout

Change in the current session the path of the history file :
export HISTFILE=/dev/null

Three ways to Remove Only Current Session Bash History and Leave Older History Untouched :
kill -9 $$
unset HISTFILE && exit
history -r && exit

The commands below does not garanted you will left no trace.
Be aware that if you make a program/script listening to a port without hidding it, it can be monitored.
Also commands you type can also be monitored (the shell can be a chroot jail for example) and log can be send via a syslog server and/or admin can be notified so be careful
source 1
source 2

2019-05-15 08:57:52

Comments

Add a Comment

Login or Register to post a Comment.

Homepage