This does work:

server:~> history | tail -100   | grep etc
  908  2018-01-17 08:53:43 cd /etc/apache2/vhosts.d/default.d/

But this does not:

ssh root@server "history | tail -100 | grep etc"


1 Answer 1


Apparently bash does not enable history handling when run non-interactively.

You can work around this by starting bash with the -i for interactive option:

ssh root@server "echo history | bash -i | tail -100 | grep etc"

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.