Query Service Running as Other User











up vote
1
down vote

favorite












I've installed a service which runs as another user (for security reasons I don't want it to run as root) and this user account is locked (i.e. can't login). Obviously now when I run commands to query this service from my user account, the command line tools run as my user and the service is not running as me and so errors are returned. Currently I'm having to use sudo -H -u username command in order to use the command line tools.



How do I make a service running as a user accessible to another user? I've tried adding my user account to the same group but no luck.



Thanks.










share|improve this question
























  • You tagged this question as systemd, but didn't mention it in your question. When your say "query the service", are you referring to using the systemctl tool?
    – Mark Stosberg
    May 17 at 11:37










  • @MarkStosberg So I'm running a service using a systemd .service file and I have a line 'user=other_user'. There is a running daemon and an admin cli tool (just like for example mysqld and mysql) but I can't query the running service with the cli tool as the service is running as another user (i.e. not me). Usually the service would run as root so sudo would do the trick. In this case access is denied from the cli tool. So it there a way to access the service as a different user with 'sudo -u -H service_username' every time? Thanks.
    – Sapient Saxon Saboo
    Jun 19 at 22:21















up vote
1
down vote

favorite












I've installed a service which runs as another user (for security reasons I don't want it to run as root) and this user account is locked (i.e. can't login). Obviously now when I run commands to query this service from my user account, the command line tools run as my user and the service is not running as me and so errors are returned. Currently I'm having to use sudo -H -u username command in order to use the command line tools.



How do I make a service running as a user accessible to another user? I've tried adding my user account to the same group but no luck.



Thanks.










share|improve this question
























  • You tagged this question as systemd, but didn't mention it in your question. When your say "query the service", are you referring to using the systemctl tool?
    – Mark Stosberg
    May 17 at 11:37










  • @MarkStosberg So I'm running a service using a systemd .service file and I have a line 'user=other_user'. There is a running daemon and an admin cli tool (just like for example mysqld and mysql) but I can't query the running service with the cli tool as the service is running as another user (i.e. not me). Usually the service would run as root so sudo would do the trick. In this case access is denied from the cli tool. So it there a way to access the service as a different user with 'sudo -u -H service_username' every time? Thanks.
    – Sapient Saxon Saboo
    Jun 19 at 22:21













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I've installed a service which runs as another user (for security reasons I don't want it to run as root) and this user account is locked (i.e. can't login). Obviously now when I run commands to query this service from my user account, the command line tools run as my user and the service is not running as me and so errors are returned. Currently I'm having to use sudo -H -u username command in order to use the command line tools.



How do I make a service running as a user accessible to another user? I've tried adding my user account to the same group but no luck.



Thanks.










share|improve this question















I've installed a service which runs as another user (for security reasons I don't want it to run as root) and this user account is locked (i.e. can't login). Obviously now when I run commands to query this service from my user account, the command line tools run as my user and the service is not running as me and so errors are returned. Currently I'm having to use sudo -H -u username command in order to use the command line tools.



How do I make a service running as a user accessible to another user? I've tried adding my user account to the same group but no luck.



Thanks.







users 18.04 services systemd






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 30 at 23:38

























asked May 5 at 23:10









Sapient Saxon Saboo

633411




633411












  • You tagged this question as systemd, but didn't mention it in your question. When your say "query the service", are you referring to using the systemctl tool?
    – Mark Stosberg
    May 17 at 11:37










  • @MarkStosberg So I'm running a service using a systemd .service file and I have a line 'user=other_user'. There is a running daemon and an admin cli tool (just like for example mysqld and mysql) but I can't query the running service with the cli tool as the service is running as another user (i.e. not me). Usually the service would run as root so sudo would do the trick. In this case access is denied from the cli tool. So it there a way to access the service as a different user with 'sudo -u -H service_username' every time? Thanks.
    – Sapient Saxon Saboo
    Jun 19 at 22:21


















  • You tagged this question as systemd, but didn't mention it in your question. When your say "query the service", are you referring to using the systemctl tool?
    – Mark Stosberg
    May 17 at 11:37










  • @MarkStosberg So I'm running a service using a systemd .service file and I have a line 'user=other_user'. There is a running daemon and an admin cli tool (just like for example mysqld and mysql) but I can't query the running service with the cli tool as the service is running as another user (i.e. not me). Usually the service would run as root so sudo would do the trick. In this case access is denied from the cli tool. So it there a way to access the service as a different user with 'sudo -u -H service_username' every time? Thanks.
    – Sapient Saxon Saboo
    Jun 19 at 22:21
















You tagged this question as systemd, but didn't mention it in your question. When your say "query the service", are you referring to using the systemctl tool?
– Mark Stosberg
May 17 at 11:37




You tagged this question as systemd, but didn't mention it in your question. When your say "query the service", are you referring to using the systemctl tool?
– Mark Stosberg
May 17 at 11:37












@MarkStosberg So I'm running a service using a systemd .service file and I have a line 'user=other_user'. There is a running daemon and an admin cli tool (just like for example mysqld and mysql) but I can't query the running service with the cli tool as the service is running as another user (i.e. not me). Usually the service would run as root so sudo would do the trick. In this case access is denied from the cli tool. So it there a way to access the service as a different user with 'sudo -u -H service_username' every time? Thanks.
– Sapient Saxon Saboo
Jun 19 at 22:21




@MarkStosberg So I'm running a service using a systemd .service file and I have a line 'user=other_user'. There is a running daemon and an admin cli tool (just like for example mysqld and mysql) but I can't query the running service with the cli tool as the service is running as another user (i.e. not me). Usually the service would run as root so sudo would do the trick. In this case access is denied from the cli tool. So it there a way to access the service as a different user with 'sudo -u -H service_username' every time? Thanks.
– Sapient Saxon Saboo
Jun 19 at 22:21










1 Answer
1






active

oldest

votes

















up vote
0
down vote













Make a one or two line bash script designed to be run as root which runs the command you want as as the other user, using su or sudo.



Add a check to the script to confirm that's only run as root to avoid strange error messages.



To run the command as another user, just sudo my-cli-tool ....



This is fast to create and memorable to use.






share|improve this answer





















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "89"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1032569%2fquery-service-running-as-other-user%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    Make a one or two line bash script designed to be run as root which runs the command you want as as the other user, using su or sudo.



    Add a check to the script to confirm that's only run as root to avoid strange error messages.



    To run the command as another user, just sudo my-cli-tool ....



    This is fast to create and memorable to use.






    share|improve this answer

























      up vote
      0
      down vote













      Make a one or two line bash script designed to be run as root which runs the command you want as as the other user, using su or sudo.



      Add a check to the script to confirm that's only run as root to avoid strange error messages.



      To run the command as another user, just sudo my-cli-tool ....



      This is fast to create and memorable to use.






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        Make a one or two line bash script designed to be run as root which runs the command you want as as the other user, using su or sudo.



        Add a check to the script to confirm that's only run as root to avoid strange error messages.



        To run the command as another user, just sudo my-cli-tool ....



        This is fast to create and memorable to use.






        share|improve this answer












        Make a one or two line bash script designed to be run as root which runs the command you want as as the other user, using su or sudo.



        Add a check to the script to confirm that's only run as root to avoid strange error messages.



        To run the command as another user, just sudo my-cli-tool ....



        This is fast to create and memorable to use.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jun 21 at 14:18









        Mark Stosberg

        2,15911525




        2,15911525






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Ask Ubuntu!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1032569%2fquery-service-running-as-other-user%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Quarter-circle Tiles

            build a pushdown automaton that recognizes the reverse language of a given pushdown automaton?

            Mont Emei