Results 1 to 8 of 8

Thread: 'history' so it shows all activty for user ?

  1. #1
    Join Date
    Dec 2009
    Beans
    19

    Question 'history' so it shows all activty for user ?

    [12.04 Server using bash]

    I start multiple, simultaneous, ssh sessions via PuTTY logging on as the same user, 'foo'.

    When I do

    Code:
    history
    I see only those commands issued on that tty (I think - I certainly don't see all the command used by user foo across each of the ssh sessions).

    Is there a way of getting around this ? I would like to have access to this history generated by each of the ssh sessions.

    (I always seem to be looking for a command I know I issued under user foo several days ago by which time that ssh session has been closed)

  2. #2
    Join Date
    Jul 2007
    Beans
    1,062
    Distro
    Ubuntu Development Release

    Re: 'history' so it shows all activty for user ?

    Quote Originally Posted by southof40 View Post
    [12.04 Server using bash]

    I start multiple, simultaneous, ssh sessions via PuTTY logging on as the same user, 'foo'.

    When I do

    Code:
    history
    I see only those commands issued on that tty (I think - I certainly don't see all the command used by user foo across each of the ssh sessions).

    Is there a way of getting around this ? I would like to have access to this history generated by each of the ssh sessions.

    (I always seem to be looking for a command I know I issued under user foo several days ago by which time that ssh session has been closed)
    I think that the way that the "history" command works is that it shows the history of the commands executed in that shell (your original local shell). Once ssh to another shell then you would have to execute the "history" command on that specific shell. I don't think that the history carries over between shells. In fact, if you have one local shell open and then open a new tab for another local shell, your history would be different for each tab.
    Maybe someone else can confirm this but I am pretty sure that it is correct. Let me know what you find out.
    "In a world without walls and fences, who needs windows and gates?" Having trouble compiling drivers in a different kernel?, Dual Boot Tutorial Ubuntu Hardware Support List

  3. #3
    Join Date
    Feb 2008
    Beans
    Hidden!

    Re: 'history' so it shows all activty for user ?

    Quote Originally Posted by southof40 View Post
    ...Is there a way of getting around this ? I would like to have access to this history generated by each of the ssh sessions
    run
    Code:
    history -c
    across all ssh sessions before running "history" in any of them.


  4. #4
    Join Date
    Jul 2007
    Beans
    1,062
    Distro
    Ubuntu Development Release

    Re: 'history' so it shows all activty for user ?

    Quote Originally Posted by Habitual View Post
    run
    Code:
    history -c
    across all ssh sessions before running "history" in any of them.
    Wouldn't that clear the history?
    "In a world without walls and fences, who needs windows and gates?" Having trouble compiling drivers in a different kernel?, Dual Boot Tutorial Ubuntu Hardware Support List

  5. #5
    Join Date
    Mar 2010
    Location
    Dublin, Ireland
    Beans
    Hidden!
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: 'history' so it shows all activty for user ?

    Quote Originally Posted by jualin View Post
    Wouldn't that clear the history?
    Yes, I think that the OP was looking for a way to log bash commands across all SSH sessions, not just clear the history file before each new login.

    This askubuntu article might help:

    http://askubuntu.com/questions/93566...rs-on-a-server

    There are a few good Linux Journal articles to read in that answer as well.
    Matt
    blog.mattrudge.net for extra helpings of geeky Ubuntu goodness
    Get the Ubuntu Weekly Newsletter

  6. #6
    Join Date
    Feb 2008
    Beans
    Hidden!

    Re: 'history' so it shows all activty for user ?

    Quote Originally Posted by jualin View Post
    Wouldn't that clear the history?
    OMG. SO SORRY.

    it's too freaking early to be doing tech support.


  7. #7
    Join Date
    Nov 2008
    Location
    Sheffield, UK
    Beans
    1,517
    Distro
    Ubuntu

    Re: 'history' so it shows all activty for user ?

    are you using different ssh keys?

    The history is wrote to after successful logout, if you don't log out you wont see the history

  8. #8
    Join Date
    Mar 2008
    Location
    Birmingham, UK
    Beans
    Hidden!

    Re: 'history' so it shows all activty for user ?

    Assuming you use bash, you can add the following in your ~/.bashrc to save commands to history after each execution, rather than at the end of a session:
    Code:
    shopt -s histappend
    [[ "${PROMPT_COMMAND}" ]] && PROMPT_COMMAND="$PROMPT_COMMAND;history -a" || PROMPT_COMMAND="history -a"
    Courtesy of the Arch Wiki - KDE
    Desktop: Phenom 955 BE | GA-MA790XT-UD4P | 8GB TG Elite 1600 | BFG GTX 275
    Conky Screenshots | Last.fm | New to Ubuntu?

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •