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.
    • gjacobseG
      gjacobse
      last edited by

      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?

      jmooreJ stacksofplatesS scottalanmillerS 3 Replies Last reply Reply Quote 0
      • jmooreJ
        jmoore @gjacobse
        last edited by

        @gjacobse I don't remember about -c specifically but I am pretty sure you can go to your bash profile and set the amount of history you want to keep.

        gjacobseG 1 Reply Last reply Reply Quote 1
        • EddieJenningsE
          EddieJennings
          last edited by

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

          But it has gotten a bit long on the Ubuntu system I have running.

          Is this causing some kind of problem?

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

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

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

            But it has gotten a bit long on the Ubuntu system I have running.

            Is this causing some kind of problem?

            Only in the sense that as I have been learning - I've made errors,.. and to prevent continuing those errors, if I clear the hsitory, I can then re-enforce the correct commands. Not to mention I copied some content, and made the mistake of pasting it back into the terminal... resulting in about 20-30 lines of meaningless junk.

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

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

              @gjacobse I don't remember about -c specifically but I am pretty sure you can go to your bash profile and set the amount of history you want to keep.

              I haven't spent any time in the bash profile. so I will look into this. Right after this call should have been an email

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

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

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

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

                But it has gotten a bit long on the Ubuntu system I have running.

                Is this causing some kind of problem?

                Only in the sense that as I have been learning - I've made errors,.. and to prevent continuing those errors, if I clear the hsitory, I can then re-enforce the correct commands. Not to mention I copied some content, and made the mistake of pasting it back into the terminal... resulting in about 20-30 lines of meaningless junk.

                I see. The environment variable you're wanting to look for is HISTSIZE, I believe.

                1 Reply Last reply Reply Quote 0
                • EddieJenningsE
                  EddieJennings
                  last edited by EddieJennings

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

                  You'll be decreasing the size instead 🙂

                  gjacobseG 1 Reply Last reply Reply Quote 0
                  • 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
                                            • 1
                                            • 2
                                            • 1 / 2
                                            • First post
                                              Last post