How to allow a regular user to run a superuser command (from /usr/sbin)

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












Running Debian 9, I would like regular users to be able to run alsactl monitor as a trigger for repainting a status bar that shows the current volume - without having to resort to polling. However, alsactl lives in /usr/sbin/, in other words, needs superuser privileges. What is the best way to enable regular users to use this command?



To define best: a good compromise between simple and restrictive. In other words, using tools that ship with Debian or are available in the repositories, as well as not having to perform deep changes in the system is a plus, as is keeping the additional rights for the users as limited as possible.



Note: I found it incredibly hard to search for this issue, yet I'm almost certain very similar questions have been asked before. If you can point me to a suitable duplicate, I'll be more than happy to delete this.







share|improve this question
















  • 2




    Just because a program is in /usr/sbin doesn't necessarily mean it demands root privileges. Have you tried running it as an ordinary user, and if so what result (or error) do you get?
    – roaima
    Jan 22 at 21:43










  • @roaima Good to know. However, I did try: alsactl: command not found
    – domsson
    Jan 22 at 21:54






  • 1




    You may be able to execute your command using the full path /usr/sbin/alsactl.
    – Timothy Martin
    Jan 22 at 22:02






  • 1




    @domsson that is simply because sbin dirs are not in regular user PATH variable. I am not 100% sure, but I rather think you still could run them by specifying the full path. Or by adding the appropriate dir to regular users path.
    – Gnudiff
    Jan 22 at 22:04










  • @TimothyMartin and Gnudiff: That works! So simple - and somewhat obvious. Yet, it would've never occurred to me. Thank you very much.
    – domsson
    Jan 22 at 22:28














up vote
0
down vote

favorite












Running Debian 9, I would like regular users to be able to run alsactl monitor as a trigger for repainting a status bar that shows the current volume - without having to resort to polling. However, alsactl lives in /usr/sbin/, in other words, needs superuser privileges. What is the best way to enable regular users to use this command?



To define best: a good compromise between simple and restrictive. In other words, using tools that ship with Debian or are available in the repositories, as well as not having to perform deep changes in the system is a plus, as is keeping the additional rights for the users as limited as possible.



Note: I found it incredibly hard to search for this issue, yet I'm almost certain very similar questions have been asked before. If you can point me to a suitable duplicate, I'll be more than happy to delete this.







share|improve this question
















  • 2




    Just because a program is in /usr/sbin doesn't necessarily mean it demands root privileges. Have you tried running it as an ordinary user, and if so what result (or error) do you get?
    – roaima
    Jan 22 at 21:43










  • @roaima Good to know. However, I did try: alsactl: command not found
    – domsson
    Jan 22 at 21:54






  • 1




    You may be able to execute your command using the full path /usr/sbin/alsactl.
    – Timothy Martin
    Jan 22 at 22:02






  • 1




    @domsson that is simply because sbin dirs are not in regular user PATH variable. I am not 100% sure, but I rather think you still could run them by specifying the full path. Or by adding the appropriate dir to regular users path.
    – Gnudiff
    Jan 22 at 22:04










  • @TimothyMartin and Gnudiff: That works! So simple - and somewhat obvious. Yet, it would've never occurred to me. Thank you very much.
    – domsson
    Jan 22 at 22:28












up vote
0
down vote

favorite









up vote
0
down vote

favorite











Running Debian 9, I would like regular users to be able to run alsactl monitor as a trigger for repainting a status bar that shows the current volume - without having to resort to polling. However, alsactl lives in /usr/sbin/, in other words, needs superuser privileges. What is the best way to enable regular users to use this command?



To define best: a good compromise between simple and restrictive. In other words, using tools that ship with Debian or are available in the repositories, as well as not having to perform deep changes in the system is a plus, as is keeping the additional rights for the users as limited as possible.



Note: I found it incredibly hard to search for this issue, yet I'm almost certain very similar questions have been asked before. If you can point me to a suitable duplicate, I'll be more than happy to delete this.







share|improve this question












Running Debian 9, I would like regular users to be able to run alsactl monitor as a trigger for repainting a status bar that shows the current volume - without having to resort to polling. However, alsactl lives in /usr/sbin/, in other words, needs superuser privileges. What is the best way to enable regular users to use this command?



To define best: a good compromise between simple and restrictive. In other words, using tools that ship with Debian or are available in the repositories, as well as not having to perform deep changes in the system is a plus, as is keeping the additional rights for the users as limited as possible.



Note: I found it incredibly hard to search for this issue, yet I'm almost certain very similar questions have been asked before. If you can point me to a suitable duplicate, I'll be more than happy to delete this.









share|improve this question











share|improve this question




share|improve this question










asked Jan 22 at 21:24









domsson

1427




1427







  • 2




    Just because a program is in /usr/sbin doesn't necessarily mean it demands root privileges. Have you tried running it as an ordinary user, and if so what result (or error) do you get?
    – roaima
    Jan 22 at 21:43










  • @roaima Good to know. However, I did try: alsactl: command not found
    – domsson
    Jan 22 at 21:54






  • 1




    You may be able to execute your command using the full path /usr/sbin/alsactl.
    – Timothy Martin
    Jan 22 at 22:02






  • 1




    @domsson that is simply because sbin dirs are not in regular user PATH variable. I am not 100% sure, but I rather think you still could run them by specifying the full path. Or by adding the appropriate dir to regular users path.
    – Gnudiff
    Jan 22 at 22:04










  • @TimothyMartin and Gnudiff: That works! So simple - and somewhat obvious. Yet, it would've never occurred to me. Thank you very much.
    – domsson
    Jan 22 at 22:28












  • 2




    Just because a program is in /usr/sbin doesn't necessarily mean it demands root privileges. Have you tried running it as an ordinary user, and if so what result (or error) do you get?
    – roaima
    Jan 22 at 21:43










  • @roaima Good to know. However, I did try: alsactl: command not found
    – domsson
    Jan 22 at 21:54






  • 1




    You may be able to execute your command using the full path /usr/sbin/alsactl.
    – Timothy Martin
    Jan 22 at 22:02






  • 1




    @domsson that is simply because sbin dirs are not in regular user PATH variable. I am not 100% sure, but I rather think you still could run them by specifying the full path. Or by adding the appropriate dir to regular users path.
    – Gnudiff
    Jan 22 at 22:04










  • @TimothyMartin and Gnudiff: That works! So simple - and somewhat obvious. Yet, it would've never occurred to me. Thank you very much.
    – domsson
    Jan 22 at 22:28







2




2




Just because a program is in /usr/sbin doesn't necessarily mean it demands root privileges. Have you tried running it as an ordinary user, and if so what result (or error) do you get?
– roaima
Jan 22 at 21:43




Just because a program is in /usr/sbin doesn't necessarily mean it demands root privileges. Have you tried running it as an ordinary user, and if so what result (or error) do you get?
– roaima
Jan 22 at 21:43












@roaima Good to know. However, I did try: alsactl: command not found
– domsson
Jan 22 at 21:54




@roaima Good to know. However, I did try: alsactl: command not found
– domsson
Jan 22 at 21:54




1




1




You may be able to execute your command using the full path /usr/sbin/alsactl.
– Timothy Martin
Jan 22 at 22:02




You may be able to execute your command using the full path /usr/sbin/alsactl.
– Timothy Martin
Jan 22 at 22:02




1




1




@domsson that is simply because sbin dirs are not in regular user PATH variable. I am not 100% sure, but I rather think you still could run them by specifying the full path. Or by adding the appropriate dir to regular users path.
– Gnudiff
Jan 22 at 22:04




@domsson that is simply because sbin dirs are not in regular user PATH variable. I am not 100% sure, but I rather think you still could run them by specifying the full path. Or by adding the appropriate dir to regular users path.
– Gnudiff
Jan 22 at 22:04












@TimothyMartin and Gnudiff: That works! So simple - and somewhat obvious. Yet, it would've never occurred to me. Thank you very much.
– domsson
Jan 22 at 22:28




@TimothyMartin and Gnudiff: That works! So simple - and somewhat obvious. Yet, it would've never occurred to me. Thank you very much.
– domsson
Jan 22 at 22:28










3 Answers
3






active

oldest

votes

















up vote
1
down vote



accepted










It should be possible to execute a command from /usr/sbin by using the absolute path to the command.



/usr/sbin/alsactl


You receive the message "alsactl: command not found" because /usr/sbin is not in the PATH of your non-superuser.






share|improve this answer



























    up vote
    1
    down vote













    You can use a sudoers rule inside /etc/sudoers file



    joe ALL=(ALL) NOPASSWD: /full/path/to/command args 


    in you case add a line like :



    user ALL=(ALL) NOPASSWD: /usr/bin/alsactl monitor


    be carefull on giving too much permissions....
    but I think alsactl isn't a command that needs sudo permissions






    share|improve this answer




















    • I assume this would require the users to run the command via sudo, so sudo alsactl monitor?
      – domsson
      Jan 22 at 21:53






    • 1




      That's correct: probably sudo /usr/sbin/alsactl monitor actually. Or if you want, you can create an one-line script in /usr/local/bin that contains exactly that command, give it a nice descriptive name and set it executable. Since /usr/local/bin should be in the default PATH for regular users, this is how you can effectively create a new command for your users.
      – telcoM
      Jan 22 at 23:01


















    up vote
    0
    down vote













    Have you tried using visudo? Or just directly editing the /etc/sudoers file?






    share|improve this answer




















    • This doesn't really answer the question, because you've omitted to mention that the OP would have to use sudo alsactl..., and they seem not to know about tools such as sudo.
      – roaima
      Jan 23 at 9:08










    • Sorry, I didn't think about that
      – Lawrence Gil
      Jan 23 at 18:05










    • You can update your answer though, and then we can delete our comments.
      – roaima
      Jan 23 at 19:46










    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    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: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );








     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f418948%2fhow-to-allow-a-regular-user-to-run-a-superuser-command-from-usr-sbin%23new-answer', 'question_page');

    );

    Post as a guest






























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote



    accepted










    It should be possible to execute a command from /usr/sbin by using the absolute path to the command.



    /usr/sbin/alsactl


    You receive the message "alsactl: command not found" because /usr/sbin is not in the PATH of your non-superuser.






    share|improve this answer
























      up vote
      1
      down vote



      accepted










      It should be possible to execute a command from /usr/sbin by using the absolute path to the command.



      /usr/sbin/alsactl


      You receive the message "alsactl: command not found" because /usr/sbin is not in the PATH of your non-superuser.






      share|improve this answer






















        up vote
        1
        down vote



        accepted







        up vote
        1
        down vote



        accepted






        It should be possible to execute a command from /usr/sbin by using the absolute path to the command.



        /usr/sbin/alsactl


        You receive the message "alsactl: command not found" because /usr/sbin is not in the PATH of your non-superuser.






        share|improve this answer












        It should be possible to execute a command from /usr/sbin by using the absolute path to the command.



        /usr/sbin/alsactl


        You receive the message "alsactl: command not found" because /usr/sbin is not in the PATH of your non-superuser.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 22 at 22:32









        Timothy Martin

        4,9542029




        4,9542029






















            up vote
            1
            down vote













            You can use a sudoers rule inside /etc/sudoers file



            joe ALL=(ALL) NOPASSWD: /full/path/to/command args 


            in you case add a line like :



            user ALL=(ALL) NOPASSWD: /usr/bin/alsactl monitor


            be carefull on giving too much permissions....
            but I think alsactl isn't a command that needs sudo permissions






            share|improve this answer




















            • I assume this would require the users to run the command via sudo, so sudo alsactl monitor?
              – domsson
              Jan 22 at 21:53






            • 1




              That's correct: probably sudo /usr/sbin/alsactl monitor actually. Or if you want, you can create an one-line script in /usr/local/bin that contains exactly that command, give it a nice descriptive name and set it executable. Since /usr/local/bin should be in the default PATH for regular users, this is how you can effectively create a new command for your users.
              – telcoM
              Jan 22 at 23:01















            up vote
            1
            down vote













            You can use a sudoers rule inside /etc/sudoers file



            joe ALL=(ALL) NOPASSWD: /full/path/to/command args 


            in you case add a line like :



            user ALL=(ALL) NOPASSWD: /usr/bin/alsactl monitor


            be carefull on giving too much permissions....
            but I think alsactl isn't a command that needs sudo permissions






            share|improve this answer




















            • I assume this would require the users to run the command via sudo, so sudo alsactl monitor?
              – domsson
              Jan 22 at 21:53






            • 1




              That's correct: probably sudo /usr/sbin/alsactl monitor actually. Or if you want, you can create an one-line script in /usr/local/bin that contains exactly that command, give it a nice descriptive name and set it executable. Since /usr/local/bin should be in the default PATH for regular users, this is how you can effectively create a new command for your users.
              – telcoM
              Jan 22 at 23:01













            up vote
            1
            down vote










            up vote
            1
            down vote









            You can use a sudoers rule inside /etc/sudoers file



            joe ALL=(ALL) NOPASSWD: /full/path/to/command args 


            in you case add a line like :



            user ALL=(ALL) NOPASSWD: /usr/bin/alsactl monitor


            be carefull on giving too much permissions....
            but I think alsactl isn't a command that needs sudo permissions






            share|improve this answer












            You can use a sudoers rule inside /etc/sudoers file



            joe ALL=(ALL) NOPASSWD: /full/path/to/command args 


            in you case add a line like :



            user ALL=(ALL) NOPASSWD: /usr/bin/alsactl monitor


            be carefull on giving too much permissions....
            but I think alsactl isn't a command that needs sudo permissions







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jan 22 at 21:43









            francois P

            914114




            914114











            • I assume this would require the users to run the command via sudo, so sudo alsactl monitor?
              – domsson
              Jan 22 at 21:53






            • 1




              That's correct: probably sudo /usr/sbin/alsactl monitor actually. Or if you want, you can create an one-line script in /usr/local/bin that contains exactly that command, give it a nice descriptive name and set it executable. Since /usr/local/bin should be in the default PATH for regular users, this is how you can effectively create a new command for your users.
              – telcoM
              Jan 22 at 23:01

















            • I assume this would require the users to run the command via sudo, so sudo alsactl monitor?
              – domsson
              Jan 22 at 21:53






            • 1




              That's correct: probably sudo /usr/sbin/alsactl monitor actually. Or if you want, you can create an one-line script in /usr/local/bin that contains exactly that command, give it a nice descriptive name and set it executable. Since /usr/local/bin should be in the default PATH for regular users, this is how you can effectively create a new command for your users.
              – telcoM
              Jan 22 at 23:01
















            I assume this would require the users to run the command via sudo, so sudo alsactl monitor?
            – domsson
            Jan 22 at 21:53




            I assume this would require the users to run the command via sudo, so sudo alsactl monitor?
            – domsson
            Jan 22 at 21:53




            1




            1




            That's correct: probably sudo /usr/sbin/alsactl monitor actually. Or if you want, you can create an one-line script in /usr/local/bin that contains exactly that command, give it a nice descriptive name and set it executable. Since /usr/local/bin should be in the default PATH for regular users, this is how you can effectively create a new command for your users.
            – telcoM
            Jan 22 at 23:01





            That's correct: probably sudo /usr/sbin/alsactl monitor actually. Or if you want, you can create an one-line script in /usr/local/bin that contains exactly that command, give it a nice descriptive name and set it executable. Since /usr/local/bin should be in the default PATH for regular users, this is how you can effectively create a new command for your users.
            – telcoM
            Jan 22 at 23:01











            up vote
            0
            down vote













            Have you tried using visudo? Or just directly editing the /etc/sudoers file?






            share|improve this answer




















            • This doesn't really answer the question, because you've omitted to mention that the OP would have to use sudo alsactl..., and they seem not to know about tools such as sudo.
              – roaima
              Jan 23 at 9:08










            • Sorry, I didn't think about that
              – Lawrence Gil
              Jan 23 at 18:05










            • You can update your answer though, and then we can delete our comments.
              – roaima
              Jan 23 at 19:46














            up vote
            0
            down vote













            Have you tried using visudo? Or just directly editing the /etc/sudoers file?






            share|improve this answer




















            • This doesn't really answer the question, because you've omitted to mention that the OP would have to use sudo alsactl..., and they seem not to know about tools such as sudo.
              – roaima
              Jan 23 at 9:08










            • Sorry, I didn't think about that
              – Lawrence Gil
              Jan 23 at 18:05










            • You can update your answer though, and then we can delete our comments.
              – roaima
              Jan 23 at 19:46












            up vote
            0
            down vote










            up vote
            0
            down vote









            Have you tried using visudo? Or just directly editing the /etc/sudoers file?






            share|improve this answer












            Have you tried using visudo? Or just directly editing the /etc/sudoers file?







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jan 22 at 21:43









            Lawrence Gil

            146




            146











            • This doesn't really answer the question, because you've omitted to mention that the OP would have to use sudo alsactl..., and they seem not to know about tools such as sudo.
              – roaima
              Jan 23 at 9:08










            • Sorry, I didn't think about that
              – Lawrence Gil
              Jan 23 at 18:05










            • You can update your answer though, and then we can delete our comments.
              – roaima
              Jan 23 at 19:46
















            • This doesn't really answer the question, because you've omitted to mention that the OP would have to use sudo alsactl..., and they seem not to know about tools such as sudo.
              – roaima
              Jan 23 at 9:08










            • Sorry, I didn't think about that
              – Lawrence Gil
              Jan 23 at 18:05










            • You can update your answer though, and then we can delete our comments.
              – roaima
              Jan 23 at 19:46















            This doesn't really answer the question, because you've omitted to mention that the OP would have to use sudo alsactl..., and they seem not to know about tools such as sudo.
            – roaima
            Jan 23 at 9:08




            This doesn't really answer the question, because you've omitted to mention that the OP would have to use sudo alsactl..., and they seem not to know about tools such as sudo.
            – roaima
            Jan 23 at 9:08












            Sorry, I didn't think about that
            – Lawrence Gil
            Jan 23 at 18:05




            Sorry, I didn't think about that
            – Lawrence Gil
            Jan 23 at 18:05












            You can update your answer though, and then we can delete our comments.
            – roaima
            Jan 23 at 19:46




            You can update your answer though, and then we can delete our comments.
            – roaima
            Jan 23 at 19:46












             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f418948%2fhow-to-allow-a-regular-user-to-run-a-superuser-command-from-usr-sbin%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay