1

Every time I ssh into a server I might issue some bash commands and then sign off (hup signal?). Is there a way to write the shell commands that I issued on the server to some changelog file?

I want to remove basic commands like ls/cd, and duplicate commands, as well. It's basically as if every command I issue in bash is like this:

eval "$(my_command | tee "$HOME/change.log")"

but I don't know how to set this up, anybody know a good way to do this?

It would be really nice to eliminate commands like ls and cd, but also show the pwd of every command that was issued:

command  (/home/ubuntu)
command1 (/root/.ssh)
command2 (/home/ubuntu/teros)
command1 (/usr/local)
command1 (/usr/local/lib)
command3 (/etc)
Alexander Mills
  • 395
  • 1
  • 3
  • 11

2 Answers2

2

Try using GNU Screen or Tmux. These are called "screen multiplexers" but you'd get a number of benefits

  1. The commands you run will continue running even if you disconnect, or you have network related connection drops. Both software allow "re-attaching" to the running session
  2. Command outputs will persist in memory. You can start a long running command, log off, then connect back some time later and see the output of the command.
  3. Save the whole shell session to a file. You can have the log of all the commands you issued, as well as the output you got, in plain text format.
hayalci
  • 136
  • 2
0

For the second part, what happens if you export PS1 in ~/.bashrc or ~/ .bash_profile

export PS1='$(whoami)@$(hostname):$(pwd)'
chicks
  • 1,911
  • 1
  • 13
  • 29
Rakib Fiha
  • 107
  • 3