Monday, April 17, 2017

Solaris 10 - deleting user command history




HISTSIZE=0

for i in `ls /export/home/*/.*profile`; do echo ls -l $i; done
for i in `ls /export/home/*/.*profile`; do grep HISTSIZE $i; done
for i in `ls /export/home/*/.*profile`; do echo "export HISTSIZE=0" >> $i; done
for i in `ls /export/home/*/.*profile`; do grep HISTSIZE $i; done
for i in `ls /export/home/*/.bash_history`; do ls -l $i; done
for i in `ls /export/home/*/.bash_history`; do cat /dev/null > $i; ls -l $i; done


1. Change root password


2. Change users home dir
chmod 700 /export/home/*


3. Remove history file
ls /export/home/*/.bash_history
cat /dev/null > /export/home/*/.bash_history

for i in `ls /export/home/*/.bash_history`; do echo $i; done
for i in `ls /export/home/*/.bash_history`; do cat /dev/null > $i; done


4. Add following to users profile
ls -l /export/home/*/.profile | more
export HISTCONTROL=ignorespace
echo "export HISTCONTROL=ignorespace" >> /export/home/*/.profile
echo "export HISTCONTROL=ignorespace" >> /export/home/*/.bash_profile
for i in `ls /export/home/*/.profile /export/home/*/.bash_profile`; do echo $i; done
for i in `ls /export/home/*/.profile /export/home/*/.bash_profile`; do echo "export HISTCONTROL=ignorespace" >> $i; done
for i in `ls /export/home/*/.profile /export/home/*/.bash_profile`; do grep HISTCONTROL $i; done
passwd kbhusal
passwd root
chmod 700 /export/home/*
for i in `ls /export/home/*/.bash_history`; do ls -l $i; done
for i in `ls /export/home/*/.bash_history`; do cat /dev/null > $i; done
for i in `ls /export/home/*/.bash_history`; do ls -l $i; done
sleep 1
for i in `ls /export/home/*/.profile /export/home/*/.bash_profile`; do echo "export HISTCONTROL=ignorespace" >> $i; done
for i in `ls /export/home/*/.profile /export/home/*/.bash_profile`; do grep HISTCONTROL $i; done
sleep 1
ls -ld /export/home/*




You can add HISTFILE=~/.hist$$ to your .profile. This should generate a unique file per session.

You can add HISTFILE=~/.hist$$ to your .profile. This should generate a unique file per session.
You can remove these files automatically by adding the following.
trap 'rm ${HISTFILE}' exit
bash stores command entries in HISTFILE (by default ~/.bash_history) and has a fixed size of how many to keep - HISTFILESIZE (by default 500). If the commands, one types, exceed that number, then history of those is lost.
Commands can also be ignored, see HISTIGNORE, as well as commands that start with a leading space - see HISTCONTROL=ignorespace. Those are not ever stored in HISTFILE.
clears the history often (history -c
savehist with csh, HISTFILE/HISTSIZE with ksh and bash). ksh records the history in real time while bash records it on shell exit so you might lose the history if the shell dies abruptly. Bash has also some setting that would prevent some commands not to appear on the history (HISTCONTROL, HISTIGNORE, HISTFILESIZE). If you have more than one interactive shell running, commands will be lost if the histappend shell option is not set with bash.

No comments:

Post a Comment