Linux tips :: Various

Custom prompt

$ export PS1=”[\d \t \u@\h:\w]$”

2015-10-28 09_35_45-caab@wrksedfsh_ ~

Logging #1

Use Putty to log commands. Can be handy for documentation

  • Change Settings… –> Session –> Logging
    • Session logging –> Printable output

PuTTY Reconfiguration

Logging #2

Turn on continuous logging

export PROMPT_COMMAND='if [ "$(id -u)" -ne 0 ]; then echo "$(date "+%Y-%m-%d.%H:%M:%S") $(pwd) $(history 1)" >> ~/.logs/bash-history-$(date "+%Y-%m-%d").log; fi'

 

Then, to find a specific command or text string is as easy as

# grep -h nmap ~/.logs/bash-history-2016-06*