Results 1 to 6 of 6

Thread: How not to get logged into BASH History Share/Save - My123World.Com!

  1. #1
    ... I am no Expert b0nd.g4h@gmail.com b0nd's Avatar
    Join Date
    Jul 2010
    Location
    irc.freenode.net #g4h
    Posts
    744

    How not to get logged into BASH History

    What if you wish to execute a command on linux console but do not wish it to be logged and displayed by #history command?
    Code:
    #history -d $((HISTCMD-1)) && type_your_command_here_and_execute
    e.g
    #history -d $((HISTCMD-1)) && whoami
    The command "whoami" would work and wouldn't be visible in #history command

    Explained in detail here
    [*] To follow the path: look to the master, follow the master, walk with the master, see through the master,
    ------> become the master!!! <------
    [*] Everyone has a will to WIN but very few have the will to prepare to WIN
    [*] Invest yourself in everything you do, there's fun in being serious

  2. #2
    Network Security Administrator Hackuin's Avatar
    Join Date
    Apr 2011
    Location
    10011001 10011001
    Posts
    104
    Quote Originally Posted by b0nd View Post
    What if you wish to execute a command on linux console but do not wish it to be logged and displayed by #history command?
    Code:
    #history -d $((HISTCMD-1)) && type_your_command_here_and_execute
    e.g
    #history -d $((HISTCMD-1)) && whoami
    The command "whoami" would work and wouldn't be visible in #history command

    Explained in detail here
    Why soo mambo jumbo when you can use "space"?
    Just give a space in front of a command and it is not logged in #history.
    Example:
    hackuin@server4$ ls [ note there is space between $ and the command ls ]

    And check your #history it will not logged there.
    "Free software" is a matter of liberty, not price. To understand the concept, you should think of "free" as in "free speech," not as in "free beer."
    "Microsoft is not the answer. Microsoft is the question. NO (or Linux) is the answer."
    "Ubuntu - Linux For Human Beings."

    Currently reading books:
    Integrating Forensic Investigation Methodology into eDiscovery -- by Colin Chisholm.
    Digital Forensics with Open Source Toolss -- by Cory Altheide && Harlan Carvey.

  3. #3
    Super Commando Dhruv abhaythehero's Avatar
    Join Date
    Sep 2010
    Location
    Lucknow/Pune,India
    Posts
    466
    Blog Entries
    2
    Why soo mambo jumbo when you can use "space"?
    Just give a space in front of a command and it is not logged in #history.
    Example:
    hackuin@server4$ ls [ note there is space between $ and the command ls ]

    And check your #history it will not logged there.

    But if we do it as root user then it is being logged by space method.

    whereas the earlier method is true for all cases .. it is working as root user as well.

    Of course if we are root then we can do anything with history ..
    but just for 1 command sake...one can prefer the earlier method
    In the world of 0s and 1s, are you a zero or The One !

  4. #4
    Network Security Administrator Hackuin's Avatar
    Join Date
    Apr 2011
    Location
    10011001 10011001
    Posts
    104
    Quote Originally Posted by abhaythehero View Post
    But if we do it as root user then it is being logged by space method.

    whereas the earlier method is true for all cases .. it is working as root user as well.

    Of course if we are root then we can do anything with history ..
    but just for 1 command sake...one can prefer the earlier method
    Actually, you did-not understand why it did not worked with root. Or why/how the b0nd's method worked. Or, why, my shown method worked for user and not for root.

    Actually, consider ubuntu [ natty ], it works for both "root" and "users" by default. But, why? because, my bash version have set my "HISTCONTORL" to "ignorespace", I am pretty sure, you are using some other distro.
    The reason is simple, check your Environmental variable "HISTCONTROL" I mean " echo $HISTCONTROL" you will not find "ignorespace" in the variable for you when you type that command with root user, where as if you type the same command with normal user you will find "ignorespace" is set in the variable "HISTCONTROL".
    Just export it like, run the command "export HISTCONTROL=ignorespace" with for your users, in your case root and check the space method will work for root too.
    Or you can just edit the file ".bashrc" of the user/root and find "HISTCONTROL" line and set "HISTCONTROL=ignorespace" and save it. It will work.

    *Note: Either way you need to log-out and log-in back to make the effect work.
    Last edited by Hackuin; 06-16-2011 at 03:55 AM. Reason: HISTCONTROL was miss-splled. And now 0ff2sleep ;}
    "Free software" is a matter of liberty, not price. To understand the concept, you should think of "free" as in "free speech," not as in "free beer."
    "Microsoft is not the answer. Microsoft is the question. NO (or Linux) is the answer."
    "Ubuntu - Linux For Human Beings."

    Currently reading books:
    Integrating Forensic Investigation Methodology into eDiscovery -- by Colin Chisholm.
    Digital Forensics with Open Source Toolss -- by Cory Altheide && Harlan Carvey.

  5. #5
    ... I am no Expert b0nd.g4h@gmail.com b0nd's Avatar
    Join Date
    Jul 2010
    Location
    irc.freenode.net #g4h
    Posts
    744
    Quote Originally Posted by Hackuin View Post
    Why soo mambo jumbo when you can use "space"?
    Just give a space in front of a command and it is not logged in #history.
    Example:
    hackuin@server4$ ls [ note there is space between $ and the command ls ]

    And check your #history it will not logged there.
    The mambo jumbo is quite useful when by mistake a command has been executed and the user wishes to remove it from history.
    Code:
    #history -d $((HISTCMD-2)) && history -d $((HISTCMD-1))
    would delete the last logged command from history.

    Definitely can be done with following as well:
    Code:
    #history -d offset
    to delete just one line
    
    #for i in {[higher-value-of-offset]..[lower-value-of-offset]}; do history -d "$i"; done;  
    to delete couple of consecutive lines
    Probably the heading I mentioned mislead the discussion.

    Thanks for the detailed explanation of <space> followed-by-command technique

    Rgds
    [*] To follow the path: look to the master, follow the master, walk with the master, see through the master,
    ------> become the master!!! <------
    [*] Everyone has a will to WIN but very few have the will to prepare to WIN
    [*] Invest yourself in everything you do, there's fun in being serious

  6. #6
    Super Commando Dhruv abhaythehero's Avatar
    Join Date
    Sep 2010
    Location
    Lucknow/Pune,India
    Posts
    466
    Blog Entries
    2
    Quote Originally Posted by Hackuin View Post
    Actually, you did-not understand why it did not worked with root. Or why/how the b0nd's method worked. Or, why, my shown method worked for user and not for root.
    yups I was using backtrack 4 and the HISTCONTROL wasn't set to ignorespace for root user by default.
    Thanks for the explanation .. I got it now
    In the world of 0s and 1s, are you a zero or The One !

Posting Permissions

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