Make user history cleaning optional in trace eraser
User bash history cleaning is now optional with a prompt, since most users only work as root. Changes: • Added user count detection • Prompts: "Clean user bash histories too? (y/n) [n]" • Default is "no" (skip user histories) • If no users exist, automatically skips • Only cleans root history by default (faster, covers 99% of use cases) This makes the script faster and more sensible for typical usage where only root is used to run the toolkit.
This commit is contained in:
@@ -73,8 +73,21 @@ if [ -f ~/.bash_history ]; then
|
|||||||
history -w
|
history -w
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Clean bash history for all users
|
# Clean bash history for all users (optional - skip if only root is used)
|
||||||
echo "→ Checking user histories..."
|
echo "→ Checking user histories..."
|
||||||
|
user_count=0
|
||||||
|
for user_home in /home/*; do
|
||||||
|
[ -d "$user_home" ] && user_count=$((user_count + 1))
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$user_count" -eq 0 ]; then
|
||||||
|
echo " ✓ No user accounts found (skipped)"
|
||||||
|
else
|
||||||
|
echo " Found $user_count user account(s)"
|
||||||
|
echo ""
|
||||||
|
read -p " Clean user bash histories too? (y/n) [n]: " clean_users
|
||||||
|
|
||||||
|
if [ "$clean_users" = "y" ] || [ "$clean_users" = "Y" ]; then
|
||||||
for user_home in /home/*; do
|
for user_home in /home/*; do
|
||||||
if [ -f "$user_home/.bash_history" ]; then
|
if [ -f "$user_home/.bash_history" ]; then
|
||||||
username=$(basename "$user_home")
|
username=$(basename "$user_home")
|
||||||
@@ -95,6 +108,11 @@ for user_home in /home/*; do
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
else
|
||||||
|
echo " ✓ Skipped user histories (only root cleaned)"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
|
||||||
# Clean system logs (pattern-based for logs, not history)
|
# Clean system logs (pattern-based for logs, not history)
|
||||||
echo "→ Cleaning system logs..."
|
echo "→ Cleaning system logs..."
|
||||||
|
|||||||
Reference in New Issue
Block a user