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

    Run ls as another user?

    IT Discussion
    linux
    4
    9
    321
    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.
    • 1
      1337
      last edited by 1337

      What's the easiest way to run ls as the apache user or similar (which you can't login to)?

      travisdh1T 1 Reply Last reply Reply Quote 0
      • travisdh1T
        travisdh1 @1337
        last edited by

        @Pete-S said in Run ls as another user?:

        What's the easiest way to run ls as the apache user (which you can't login as)?

        su -u apache ls

        1 scottalanmillerS 2 Replies Last reply Reply Quote 1
        • 1
          1337 @travisdh1
          last edited by

          @travisdh1 said in Run ls as apache user?:

          @Pete-S said in Run ls as another user?:

          What's the easiest way to run ls as the apache user (which you can't login as)?

          su -u apache ls

          Did you mean sudo or su?

          Because you can't do su apache . You get "This account is currently not available.".

          wirestyle22W travisdh1T 2 Replies Last reply Reply Quote 0
          • wirestyle22W
            wirestyle22 @1337
            last edited by wirestyle22

            This post is deleted!
            1 Reply Last reply Reply Quote 0
            • travisdh1T
              travisdh1 @1337
              last edited by travisdh1

              @Pete-S said in Run ls as another user?:

              @travisdh1 said in Run ls as apache user?:

              @Pete-S said in Run ls as another user?:

              What's the easiest way to run ls as the apache user (which you can't login as)?

              su -u apache ls

              Did you mean sudo or su?

              Because you can't do su apache . You get "This account is currently not available.".

              I know the -u apache is needed to run a command as a user from su or sudo. I'm thinking the issue might be with the apache account being set to nologin in /etc/passwd. Just be sure to change the shell entry in passwd back when you finish up.

              1 scottalanmillerS 2 Replies Last reply Reply Quote 0
              • 1
                1337 @travisdh1
                last edited by

                @travisdh1 said in Run ls as another user?:

                @Pete-S said in Run ls as another user?:

                @travisdh1 said in Run ls as apache user?:

                @Pete-S said in Run ls as another user?:

                What's the easiest way to run ls as the apache user (which you can't login as)?

                su -u apache ls

                Did you mean sudo or su?

                Because you can't do su apache . You get "This account is currently not available.".

                I know the -u apache is needed to run a command as a user from su or sudo. I'm thinking the issue might be with the apache account being set to nologin in /etc/passwd. Just be sure to change the shell entry in passwd back when you finish up.

                I'd rather not change anything on the user account if possible.

                Accounts such as apache that can't login, doesn't have a shell etc, are used for daemons, but I want to be able to run commands as that daemon user for troubleshooting. I'm thinking that if I am root there should be a way to do that.

                travisdh1T 1 Reply Last reply Reply Quote 1
                • travisdh1T
                  travisdh1 @1337
                  last edited by

                  @Pete-S said in Run ls as another user?:

                  @travisdh1 said in Run ls as another user?:

                  @Pete-S said in Run ls as another user?:

                  @travisdh1 said in Run ls as apache user?:

                  @Pete-S said in Run ls as another user?:

                  What's the easiest way to run ls as the apache user (which you can't login as)?

                  su -u apache ls

                  Did you mean sudo or su?

                  Because you can't do su apache . You get "This account is currently not available.".

                  I know the -u apache is needed to run a command as a user from su or sudo. I'm thinking the issue might be with the apache account being set to nologin in /etc/passwd. Just be sure to change the shell entry in passwd back when you finish up.

                  I'd rather not change anything on the user account if possible.

                  Accounts such as apache that can't login, doesn't have a shell etc, are used for daemons, but I want to be able to run commands as that daemon user for troubleshooting. I'm thinking that if I am root there should be a way to do that.

                  You'd think so, I just don't know how to do it easily if it's not working with either su or sudo for you.

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

                    @travisdh1 said in Run ls as another user?:

                    @Pete-S said in Run ls as another user?:

                    What's the easiest way to run ls as the apache user (which you can't login as)?

                    su -u apache ls

                    It's ...

                    sudo -u apache ls
                    
                    1 Reply Last reply Reply Quote 0
                    • scottalanmillerS
                      scottalanmiller @travisdh1
                      last edited by

                      @travisdh1 said in Run ls as another user?:

                      @Pete-S said in Run ls as another user?:

                      @travisdh1 said in Run ls as apache user?:

                      @Pete-S said in Run ls as another user?:

                      What's the easiest way to run ls as the apache user (which you can't login as)?

                      su -u apache ls

                      Did you mean sudo or su?

                      Because you can't do su apache . You get "This account is currently not available.".

                      I know the -u apache is needed to run a command as a user from su or sudo. I'm thinking the issue might be with the apache account being set to nologin in /etc/passwd. Just be sure to change the shell entry in passwd back when you finish up.

                      -u is the user for either, but sudo is a loginless command and su uses login. To use su like you are thinking, you also need -c to make it a single command. Both will work, but only sudo will work for a non-login user like this without the -c

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