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

    Newb question - Running a script from the root directory

    IT Discussion
    scripts centos centos7 linux education
    7
    29
    4.2k
    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.
    • D
      Dashrender
      last edited by

      add the directory to the path variable.

      D 1 Reply Last reply Reply Quote 1
      • D
        DustinB3403 @Dashrender
        last edited by

        @dashrender said in Newb question - Running a script from the root directory:

        add the directory to the path variable.

        Any guidance on that process?

        D 1 Reply Last reply Reply Quote 0
        • D
          Dashrender @DustinB3403
          last edited by

          @dustinb3403 said in Newb question - Running a script from the root directory:

          @dashrender said in Newb question - Running a script from the root directory:

          add the directory to the path variable.

          Any guidance on that process?

          For Windows, sure, nix - not a clue - google would be my friend.

          1 Reply Last reply Reply Quote 0
          • D
            Danp
            last edited by

            Is the directory in your path? What do you get from echo $PATH?

            S D 2 Replies Last reply Reply Quote 1
            • S
              scottalanmiller
              last edited by

              What user are you trying to run it as?

              Also, consider using a file location already designated for this instead. Like /usr/local/bin

              D 1 Reply Last reply Reply Quote 3
              • S
                scottalanmiller @Danp
                last edited by

                @danp said in Newb question - Running a script from the root directory:

                Is the directory in your path? What do you get from echo $PATH?

                Nothing in /opt would be by default.

                1 Reply Last reply Reply Quote 2
                • D
                  DustinB3403 @Danp
                  last edited by

                  @danp said in Newb question - Running a script from the root directory:

                  Is the directory in your path? What do you get from echo $PATH?

                  echo $PATH
                  /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/root/opt/scripts/:/root/opt/scripts

                  I've added it (twice).

                  S 1 Reply Last reply Reply Quote 0
                  • D
                    DustinB3403
                    last edited by

                    OK that works just putting the script into /usr/local/bin

                    So much easier, now just to remove the custom paths. . .

                    1 Reply Last reply Reply Quote 1
                    • D
                      DustinB3403
                      last edited by DustinB3403

                      Figured out how to remove the entries as well.

                      export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

                      Damn that's easy.

                      E 1 Reply Last reply Reply Quote 1
                      • E
                        EddieJennings @DustinB3403
                        last edited by EddieJennings

                        @dustinb3403 said in Newb question - Running a script from the root directory:

                        Figured out how to remove the entries as well.

                        export PATH=/export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

                        Damn that's easy.

                        The more I learn, the more I realize that doing $TASKS in a Linux environment usually results in "Damn, that's easy."

                        B 1 Reply Last reply Reply Quote 4
                        • D
                          DustinB3403 @scottalanmiller
                          last edited by

                          @scottalanmiller said in Newb question - Running a script from the root directory:

                          What user are you trying to run it as?

                          Also, consider using a file location already designated for this instead. Like /usr/local/bin

                          As the root user.

                          1 Reply Last reply Reply Quote 0
                          • B
                            BRRABill @EddieJennings
                            last edited by

                            @eddiejennings said in Newb question - Running a script from the root directory:

                            @dustinb3403 said in Newb question - Running a script from the root directory:

                            Figured out how to remove the entries as well.

                            export PATH=/export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

                            Damn that's easy.

                            The more I learn, the more I realize that doing $TASKS in a Linux environment usually results in "Damn, that's easy."

                            @scottalanmiller often tells me (paraphrased):
                            "You are making this much tougher on yourself because you are thinking about it like Windows. This is just ... EASY."

                            1 Reply Last reply Reply Quote 2
                            • S
                              stacksofplates @DustinB3403
                              last edited by stacksofplates

                              @dustinb3403 said in Newb question - Running a script from the root directory:

                              @danp said in Newb question - Running a script from the root directory:

                              Is the directory in your path? What do you get from echo $PATH?

                              echo $PATH
                              /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/root/opt/scripts/:/root/opt/scripts

                              I've added it (twice).

                              Well first off you had /root/opt/scripts not /opt/scripts. Second you either have to log out and back in or tell your user to use the new path with something like

                              source ~/.bash_profile
                              

                              I always put machine specific scripts in /use/local/bin. If I need to share them they are usually auto mounted.

                              D 1 Reply Last reply Reply Quote 1
                              • D
                                DustinB3403 @stacksofplates
                                last edited by

                                @stacksofplates said in Newb question - Running a script from the root directory:

                                @dustinb3403 said in Newb question - Running a script from the root directory:

                                @danp said in Newb question - Running a script from the root directory:

                                Is the directory in your path? What do you get from echo $PATH?

                                echo $PATH
                                /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/root/opt/scripts/:/root/opt/scripts

                                I've added it (twice).

                                Well first off you had /root/opt/scripts not /opt/scripts. Second you either have to log out and back in or tell your user to use the new path with something like

                                source ~/.bash_profile
                                

                                I used ````~/opt/scripts``` initially, as I wasn't aware of just adding my scripts into one of the existing locations. (everything said just add a new directory).

                                By simply moving the script into an already existing path, I am able to update with just "script.sh".

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

                                  @dustinb3403 said in Newb question - Running a script from the root directory:

                                  @stacksofplates said in Newb question - Running a script from the root directory:

                                  @dustinb3403 said in Newb question - Running a script from the root directory:

                                  @danp said in Newb question - Running a script from the root directory:

                                  Is the directory in your path? What do you get from echo $PATH?

                                  echo $PATH
                                  /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/root/opt/scripts/:/root/opt/scripts

                                  I've added it (twice).

                                  Well first off you had /root/opt/scripts not /opt/scripts. Second you either have to log out and back in or tell your user to use the new path with something like

                                  source ~/.bash_profile
                                  

                                  I used ````~/opt/scripts``` initially, as I wasn't aware of just adding my scripts into one of the existing locations. (everything said just add a new directory).

                                  By simply moving the script into an already existing path, I am able to update with just "script.sh".

                                  When you are root and your home is /root and you put ~/opt/scripts that is /root/opt/scripts.

                                  Remember that ~ is a shortcut to your home directory, which is /root

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

                                    @scottalanmiller said in Newb question - Running a script from the root directory:

                                    @dustinb3403 said in Newb question - Running a script from the root directory:

                                    @stacksofplates said in Newb question - Running a script from the root directory:

                                    @dustinb3403 said in Newb question - Running a script from the root directory:

                                    @danp said in Newb question - Running a script from the root directory:

                                    Is the directory in your path? What do you get from echo $PATH?

                                    echo $PATH
                                    /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/root/opt/scripts/:/root/opt/scripts

                                    I've added it (twice).

                                    Well first off you had /root/opt/scripts not /opt/scripts. Second you either have to log out and back in or tell your user to use the new path with something like

                                    source ~/.bash_profile
                                    

                                    I used ````~/opt/scripts``` initially, as I wasn't aware of just adding my scripts into one of the existing locations. (everything said just add a new directory).

                                    By simply moving the script into an already existing path, I am able to update with just "script.sh".

                                    When you are root and your home is /root and you put ~/opt/scripts that is /root/opt/scripts.

                                    Remember that ~ is a shortcut to your home directory, which is /root

                                    So by adding /opt/scripts/ this would've worked, but would've added complexity for no reason.

                                    S S 2 Replies Last reply Reply Quote 0
                                    • S
                                      scottalanmiller @DustinB3403
                                      last edited by

                                      @dustinb3403 said in Newb question - Running a script from the root directory:

                                      @scottalanmiller said in Newb question - Running a script from the root directory:

                                      @dustinb3403 said in Newb question - Running a script from the root directory:

                                      @stacksofplates said in Newb question - Running a script from the root directory:

                                      @dustinb3403 said in Newb question - Running a script from the root directory:

                                      @danp said in Newb question - Running a script from the root directory:

                                      Is the directory in your path? What do you get from echo $PATH?

                                      echo $PATH
                                      /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/root/opt/scripts/:/root/opt/scripts

                                      I've added it (twice).

                                      Well first off you had /root/opt/scripts not /opt/scripts. Second you either have to log out and back in or tell your user to use the new path with something like

                                      source ~/.bash_profile
                                      

                                      I used ````~/opt/scripts``` initially, as I wasn't aware of just adding my scripts into one of the existing locations. (everything said just add a new directory).

                                      By simply moving the script into an already existing path, I am able to update with just "script.sh".

                                      When you are root and your home is /root and you put ~/opt/scripts that is /root/opt/scripts.

                                      Remember that ~ is a shortcut to your home directory, which is /root

                                      So by adding ```/opt/scripts/```` this would've worked, but would've added complexity for no reason.

                                      Why so many quotes?

                                      Yes, /opt/scripts would work, /root/opt/scripts does, too. Neither is a good location.

                                      D 1 Reply Last reply Reply Quote 1
                                      • S
                                        stacksofplates @DustinB3403
                                        last edited by

                                        @dustinb3403 said in Newb question - Running a script from the root directory:

                                        @scottalanmiller said in Newb question - Running a script from the root directory:

                                        @dustinb3403 said in Newb question - Running a script from the root directory:

                                        @stacksofplates said in Newb question - Running a script from the root directory:

                                        @dustinb3403 said in Newb question - Running a script from the root directory:

                                        @danp said in Newb question - Running a script from the root directory:

                                        Is the directory in your path? What do you get from echo $PATH?

                                        echo $PATH
                                        /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/root/opt/scripts/:/root/opt/scripts

                                        I've added it (twice).

                                        Well first off you had /root/opt/scripts not /opt/scripts. Second you either have to log out and back in or tell your user to use the new path with something like

                                        source ~/.bash_profile
                                        

                                        I used ````~/opt/scripts``` initially, as I wasn't aware of just adding my scripts into one of the existing locations. (everything said just add a new directory).

                                        By simply moving the script into an already existing path, I am able to update with just "script.sh".

                                        When you are root and your home is /root and you put ~/opt/scripts that is /root/opt/scripts.

                                        Remember that ~ is a shortcut to your home directory, which is /root

                                        So by adding ```/opt/scripts/```` this would've worked, but would've added complexity for no reason.

                                        No that still isn’t a default location. In the OP you said you put the script in /opt/scripts. Where did you actually put it?

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

                                          @scottalanmiller said in Newb question - Running a script from the root directory:

                                          @dustinb3403 said in Newb question - Running a script from the root directory:

                                          @scottalanmiller said in Newb question - Running a script from the root directory:

                                          @dustinb3403 said in Newb question - Running a script from the root directory:

                                          @stacksofplates said in Newb question - Running a script from the root directory:

                                          @dustinb3403 said in Newb question - Running a script from the root directory:

                                          @danp said in Newb question - Running a script from the root directory:

                                          Is the directory in your path? What do you get from echo $PATH?

                                          echo $PATH
                                          /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/root/opt/scripts/:/root/opt/scripts

                                          I've added it (twice).

                                          Well first off you had /root/opt/scripts not /opt/scripts. Second you either have to log out and back in or tell your user to use the new path with something like

                                          source ~/.bash_profile
                                          

                                          I used ````~/opt/scripts``` initially, as I wasn't aware of just adding my scripts into one of the existing locations. (everything said just add a new directory).

                                          By simply moving the script into an already existing path, I am able to update with just "script.sh".

                                          When you are root and your home is /root and you put ~/opt/scripts that is /root/opt/scripts.

                                          Remember that ~ is a shortcut to your home directory, which is /root

                                          So by adding /opt/scripts/ this would've worked, but would've added complexity for no reason.

                                          Why so many quotes?

                                          Yes, /opt/scripts would work, /root/opt/scripts does, too. Neither is a good location.

                                          Grr those aren't quotes those are the red code markdown.... and I added to many.... sorry typo error.

                                          1 Reply Last reply Reply Quote 0
                                          • D
                                            DustinB3403 @stacksofplates
                                            last edited by DustinB3403

                                            @stacksofplates said in Newb question - Running a script from the root directory:

                                            @dustinb3403 said in Newb question - Running a script from the root directory:

                                            @scottalanmiller said in Newb question - Running a script from the root directory:

                                            @dustinb3403 said in Newb question - Running a script from the root directory:

                                            @stacksofplates said in Newb question - Running a script from the root directory:

                                            @dustinb3403 said in Newb question - Running a script from the root directory:

                                            @danp said in Newb question - Running a script from the root directory:

                                            Is the directory in your path? What do you get from echo $PATH?

                                            echo $PATH
                                            /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/root/opt/scripts/:/root/opt/scripts

                                            I've added it (twice).

                                            Well first off you had /root/opt/scripts not /opt/scripts. Second you either have to log out and back in or tell your user to use the new path with something like

                                            source ~/.bash_profile
                                            

                                            I used ````~/opt/scripts``` initially, as I wasn't aware of just adding my scripts into one of the existing locations. (everything said just add a new directory).

                                            By simply moving the script into an already existing path, I am able to update with just "script.sh".

                                            When you are root and your home is /root and you put ~/opt/scripts that is /root/opt/scripts.

                                            Remember that ~ is a shortcut to your home directory, which is /root

                                            So by adding ```/opt/scripts/```` this would've worked, but would've added complexity for no reason.

                                            No that still isn’t a default location. In the OP you said you put the script in /opt/scripts. Where did you actually put it?

                                            Originally I created the directory /opt/scripts and put the script in there so the Directory looked like

                                            /opt/scripts/script.sh

                                            I went back and change the script location to be in /usr/local/bin

                                            So in /usr/local/bin I now have script.sh

                                            This now works without issue, and /opt/scripts no longer exists.

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