How to allow a regular user to run a superuser command (from /usr/sbin)
Clash 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.
permissions
add a comment |Â
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.
permissions
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
add a comment |Â
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.
permissions
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.
permissions
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
add a comment |Â
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
add a comment |Â
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.
add a comment |Â
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
I assume this would require the users to run the command via sudo, sosudo alsactl monitor
?
â domsson
Jan 22 at 21:53
1
That's correct: probablysudo /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 defaultPATH
for regular users, this is how you can effectively create a new command for your users.
â telcoM
Jan 22 at 23:01
add a comment |Â
up vote
0
down vote
Have you tried using visudo? Or just directly editing the /etc/sudoers file?
This doesn't really answer the question, because you've omitted to mention that the OP would have to usesudo alsactl...
, and they seem not to know about tools such assudo
.
â 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
add a comment |Â
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.
add a comment |Â
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.
add a comment |Â
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.
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.
answered Jan 22 at 22:32
Timothy Martin
4,9542029
4,9542029
add a comment |Â
add a comment |Â
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
I assume this would require the users to run the command via sudo, sosudo alsactl monitor
?
â domsson
Jan 22 at 21:53
1
That's correct: probablysudo /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 defaultPATH
for regular users, this is how you can effectively create a new command for your users.
â telcoM
Jan 22 at 23:01
add a comment |Â
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
I assume this would require the users to run the command via sudo, sosudo alsactl monitor
?
â domsson
Jan 22 at 21:53
1
That's correct: probablysudo /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 defaultPATH
for regular users, this is how you can effectively create a new command for your users.
â telcoM
Jan 22 at 23:01
add a comment |Â
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
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
answered Jan 22 at 21:43
francois P
914114
914114
I assume this would require the users to run the command via sudo, sosudo alsactl monitor
?
â domsson
Jan 22 at 21:53
1
That's correct: probablysudo /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 defaultPATH
for regular users, this is how you can effectively create a new command for your users.
â telcoM
Jan 22 at 23:01
add a comment |Â
I assume this would require the users to run the command via sudo, sosudo alsactl monitor
?
â domsson
Jan 22 at 21:53
1
That's correct: probablysudo /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 defaultPATH
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
add a comment |Â
up vote
0
down vote
Have you tried using visudo? Or just directly editing the /etc/sudoers file?
This doesn't really answer the question, because you've omitted to mention that the OP would have to usesudo alsactl...
, and they seem not to know about tools such assudo
.
â 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
add a comment |Â
up vote
0
down vote
Have you tried using visudo? Or just directly editing the /etc/sudoers file?
This doesn't really answer the question, because you've omitted to mention that the OP would have to usesudo alsactl...
, and they seem not to know about tools such assudo
.
â 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
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Have you tried using visudo? Or just directly editing the /etc/sudoers file?
Have you tried using visudo? Or just directly editing the /etc/sudoers file?
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 usesudo alsactl...
, and they seem not to know about tools such assudo
.
â 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
add a comment |Â
This doesn't really answer the question, because you've omitted to mention that the OP would have to usesudo alsactl...
, and they seem not to know about tools such assudo
.
â 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
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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