Find the answer to your Linux question:
Results 1 to 10 of 10
hi i was reading this in the tutorial Guide for people new to linux command line clear cmd line history Code: rm /home/joe/.bash_history (from home dir of user) doesn't seem ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie
    Join Date
    Mar 2005
    Location
    Bangalore, INDIA
    Posts
    122

    cmd line history


    hi
    i was reading this in the tutorial Guide for people new to linux command line

    clear cmd line history
    Code:
    rm /home/joe/.bash_history (from home dir of user)
    doesn't seem to work;
    anyreason why ???
    thank you
    Portability is for people who cannot programme

  2. #2
    Linux Guru Vergil83's Avatar
    Join Date
    Mar 2004
    Posts
    2,407
    you are using bash correct?
    Brilliant Mediocrity - Making Failure Look Good

  3. #3
    Linux Engineer
    Join Date
    Mar 2005
    Location
    Where my hat is
    Posts
    766
    What are the permissions on the file? I was able to whack mine fairly easily.
    Registered Linux user #384279
    Vector Linux SOHO 7

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Newbie
    Join Date
    Mar 2005
    Location
    Bangalore, INDIA
    Posts
    122
    Quote Originally Posted by Vergil83
    you are using bash correct?
    yes
    Portability is for people who cannot programme

  6. #5
    Linux Newbie
    Join Date
    Mar 2005
    Location
    Bangalore, INDIA
    Posts
    122
    Quote Originally Posted by retired1af
    What are the permissions on the file? I was able to whack mine fairly easily.
    i have already deleted the file .bash_history
    anyways it was read write for the owner only
    ie 600
    Portability is for people who cannot programme

  7. #6
    Linux Engineer
    Join Date
    Mar 2005
    Location
    Where my hat is
    Posts
    766
    So the rm command did work? Or are you asking why does it still keep track of the commands?
    Registered Linux user #384279
    Vector Linux SOHO 7

  8. #7
    Linux Newbie
    Join Date
    Mar 2005
    Location
    Bangalore, INDIA
    Posts
    122
    Quote Originally Posted by retired1af
    So the rm command did work? Or are you asking why does it still keep track of the commands?
    yes why does it still keep track of the commands?
    Portability is for people who cannot programme

  9. #8
    Linux Engineer
    Join Date
    Mar 2005
    Location
    Where my hat is
    Posts
    766
    Because it's supposed to.

    Deleting the file just erases the history up to that point. The system is still going to keep track of what the user did at the console. It'll just create a new file and keep on recording.
    Registered Linux user #384279
    Vector Linux SOHO 7

  10. #9
    Linux Newbie
    Join Date
    Jul 2004
    Location
    Calcutta, India
    Posts
    220
    Actually deleting the .bash_history only works for uptil the previous session. In your current session at console, tthe commands you type are NOT immediately entered in the .bash_history. They are kept in some kinda buffer, maybe memory, I am not sure. Whenever you type exit and leave the console or bash prompt, the bash APPENDS your current session commands in that history file. That is why you are NOT able to clear the total history of commands. For eg.,
    suppose in the current session, the various cmds, u gave were as follows :
    Code:
    $ clear
    $ ls -l
    $ pwd
    $ cd somedir
    $ rm ~/.bash_history
    $ clear
    $ exit
    Notice the line where I del the history file. Now these cmds have not been entered in the .bash_history file when I executed that rm ~/.bash_history cmd. these cmds are entered in the history only after I type tht exit . So, the next time you login to bash, and hit the UP arrow key, you'll first see the exit, then clear and so on.

    Hope this helps ..

  11. #10
    Linux User
    Join Date
    Oct 2004
    Location
    Serbia&Montenegro
    Posts
    281
    Nice, very nice ...
    Linux registered user #358842
    Human knowledge belongs to the world.

Posting Permissions

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