text: how to trap commands entered on the unix command prompt? i want to trap any command(s) entered on the linux command prompt. this would help to maintain my own version of .sh_history file. a background process, can apply hooks for keyboard and keeps them all. you can launch that process upon login. either through per user or all user login script.