ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Solved Linux History: Not clearing between -

    IT Discussion
    7
    24
    605
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • stacksofplatesS
      stacksofplates @gjacobse
      last edited by stacksofplates

      @gjacobse said in Linux History: Not clearing between -:

      History is a great tool to have - But it has gotten a bit long on the Ubuntu system I have running.

      Accessing from Windows - it's aver 180 lines now,.. and I've cleared it via history -c. Yet when I access the same system from Termius all 180(+) lines are there. Running history -c clears, but then on Windows - it's still there.

      This is using the same sign-on, just a different device in which the system is accessed.

      To not make assumptions - am I interrupting how the -c works incorrectly? Or should it indeed clear it regardless of access source?

      which Ubuntu? There was a bug in older ones (maybe current too not sure) that it didn't clear the history.

      You can try history -cw but if that doesn't work just echo "" > ~/.bash_history

      1 Reply Last reply Reply Quote 1
      • gjacobseG
        gjacobse @EddieJennings
        last edited by

        @EddieJennings said in Linux History: Not clearing between -:

        https://eshlox.net/2017/08/01/bash-increase-command-history-size

        You'll be decreasing the size instead 🙂

        I don't know that the size is so much of an issue as the inability of deleting it. Having 200 lines is fine -

        1 Reply Last reply Reply Quote 0
        • gjacobseG
          gjacobse
          last edited by

          So - this is my confusion now:

          root@TuDallasNC:~# echo "$HISTFILE"
          /root/.bash_history
          root@TuDallasNC:~# sudo vi /root/bash_history
          
          ~
          ~
          ~
          ~
          

          The listed history file is - well - blank. But obviously - it isn't as it's now 202 lines (default seems to be set to 1000)

          Incidently - when I do execute the history -c it clears - but when i re-connect it is still there.

          jmooreJ 1 Reply Last reply Reply Quote 0
          • jmooreJ
            jmoore @gjacobse
            last edited by

            @gjacobse wouldn't the . be part of the filename though? So it would be "sudo vi /root/.bash_history"

            gjacobseG 1 Reply Last reply Reply Quote 0
            • gjacobseG
              gjacobse @jmoore
              last edited by

              @jmoore said in Linux History: Not clearing between -:

              @gjacobse wouldn't the . be part of the filename though? So it would be "sudo vi /root/.bash_history"

              Quite true indeed - so I missed i there,.. but didn't here: 190 sudo nano ~/.bash.history

              1 Reply Last reply Reply Quote 0
              • gjacobseG
                gjacobse
                last edited by

                This has been helpful - I've managed to edit the file, and after making a backup, and editing it down to clear out the garbage.

                scottalanmillerS 1 Reply Last reply Reply Quote 0
                • DustinB3403D
                  DustinB3403
                  last edited by DustinB3403

                  You also could've run history -d linenumber to have removed things that were incorrect or frivolous.

                  gjacobseG 1 Reply Last reply Reply Quote 0
                  • scottalanmillerS
                    scottalanmiller @gjacobse
                    last edited by

                    @gjacobse said in Linux History: Not clearing between -:

                    History is a great tool to have - But it has gotten a bit long on the Ubuntu system I have running.

                    A bit long would be like.... 100,000 lines?

                    1 Reply Last reply Reply Quote 0
                    • scottalanmillerS
                      scottalanmiller @gjacobse
                      last edited by

                      @gjacobse said in Linux History: Not clearing between -:

                      This has been helpful - I've managed to edit the file, and after making a backup, and editing it down to clear out the garbage.

                      It's a history, clearing stuff out doesn't really make sense.

                      DustinB3403D IRJI 2 Replies Last reply Reply Quote 1
                      • gjacobseG
                        gjacobse @DustinB3403
                        last edited by

                        @DustinB3403 said in Linux History: Not clearing between -:

                        You also could've run history -d linenumber to have removed things that were incorrect or frivolous.

                        Done that also - didn't do anymore than history -c did.

                        1 Reply Last reply Reply Quote 0
                        • DustinB3403D
                          DustinB3403 @scottalanmiller
                          last edited by

                          @scottalanmiller said in Linux History: Not clearing between -:

                          @gjacobse said in Linux History: Not clearing between -:

                          This has been helpful - I've managed to edit the file, and after making a backup, and editing it down to clear out the garbage.

                          It's a history, clearing stuff out doesn't really make sense.

                          It does if he wants to document a process to getting something to work and only having valid commands visible.

                          If he had a typo or whatever else, leaving that in the history could cause issues later.

                          IRJI scottalanmillerS 2 Replies Last reply Reply Quote 1
                          • IRJI
                            IRJ @scottalanmiller
                            last edited by

                            @scottalanmiller said in Linux History: Not clearing between -:

                            @gjacobse said in Linux History: Not clearing between -:

                            This has been helpful - I've managed to edit the file, and after making a backup, and editing it down to clear out the garbage.

                            It's a history, clearing stuff out doesn't really make sense.

                            And could possibly be seen as malicious intent.

                            1 Reply Last reply Reply Quote 1
                            • IRJI
                              IRJ @DustinB3403
                              last edited by

                              @DustinB3403 said in Linux History: Not clearing between -:

                              @scottalanmiller said in Linux History: Not clearing between -:

                              @gjacobse said in Linux History: Not clearing between -:

                              This has been helpful - I've managed to edit the file, and after making a backup, and editing it down to clear out the garbage.

                              It's a history, clearing stuff out doesn't really make sense.

                              It does if he wants to document a process to getting something to work and only having valid commands visible.

                              If he had a typo or whatever else, leaving that in the history could cause issues later.

                              Still doesnt make sense, because if you know which line is incorrect, just dont copy that line. You still have to know which line is incorrect to delete 🤦

                              1 Reply Last reply Reply Quote 1
                              • scottalanmillerS
                                scottalanmiller @DustinB3403
                                last edited by

                                @DustinB3403 said in Linux History: Not clearing between -:

                                It does if he wants to document a process to getting something to work and only having valid commands visible.

                                History isn't documentation once it is edited.

                                IRJI 1 Reply Last reply Reply Quote 0
                                • IRJI
                                  IRJ @scottalanmiller
                                  last edited by

                                  @scottalanmiller said in Linux History: Not clearing between -:

                                  @DustinB3403 said in Linux History: Not clearing between -:

                                  It does if he wants to document a process to getting something to work and only having valid commands visible.

                                  History isn't documentation

                                  I fixed it for you

                                  1 Reply Last reply Reply Quote 1
                                  • IRJI
                                    IRJ
                                    last edited by

                                    Also, what if an incorrect command screws something up? Then you lose your ability to check history for troubleshooting. You should never be deleting any history.

                                    stacksofplatesS 1 Reply Last reply Reply Quote 3
                                    • stacksofplatesS
                                      stacksofplates @IRJ
                                      last edited by

                                      @IRJ said in Linux History: Not clearing between -:

                                      Also, what if an incorrect command screws something up? Then you lose your ability to check history for troubleshooting. You should never be deleting any history.

                                      I use zsh with autocomplete so I rely on history pretty heavily

                                      1 Reply Last reply Reply Quote 0
                                      • 1
                                      • 2
                                      • 1 / 2
                                      • First post
                                        Last post