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)
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.
  • Incidentally, tmux is much easier to automate than screen. – chicks May 14 at 1:35
0

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

export PS1='$(whoami)@$(hostname):$(pwd)'
  • It seems strange to loop through $(pwd) when it only returns on thing. – chicks May 14 at 1:41
  • Right. I think, exporting PS1 would be better – Rakib Fiha May 14 at 1:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.