run a particular method using sudo

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











up vote
0
down vote

favorite












How to run a single command in rhel for a particular user



e.g: only ls command should execute, if we try for other commands we should get a error like permission denied



I am uisng visduo file and created a user and assigned a permission like



abhitest ALL=(ALL) /bin/ls


and I tried too abhitest ALL=/bin/ls



but its not working







share|improve this question






















  • This would allow user abhitest to run sudo -u <any other user> ls <any parameters>, i.e. the user would be able to run the ls command with any parameters as any user, including root. But it would have no effect at all for commands run as user abhitest: if you want that, you need to set up a restricted shell for that user.
    – telcoM
    Mar 6 at 10:37














up vote
0
down vote

favorite












How to run a single command in rhel for a particular user



e.g: only ls command should execute, if we try for other commands we should get a error like permission denied



I am uisng visduo file and created a user and assigned a permission like



abhitest ALL=(ALL) /bin/ls


and I tried too abhitest ALL=/bin/ls



but its not working







share|improve this question






















  • This would allow user abhitest to run sudo -u <any other user> ls <any parameters>, i.e. the user would be able to run the ls command with any parameters as any user, including root. But it would have no effect at all for commands run as user abhitest: if you want that, you need to set up a restricted shell for that user.
    – telcoM
    Mar 6 at 10:37












up vote
0
down vote

favorite









up vote
0
down vote

favorite











How to run a single command in rhel for a particular user



e.g: only ls command should execute, if we try for other commands we should get a error like permission denied



I am uisng visduo file and created a user and assigned a permission like



abhitest ALL=(ALL) /bin/ls


and I tried too abhitest ALL=/bin/ls



but its not working







share|improve this question














How to run a single command in rhel for a particular user



e.g: only ls command should execute, if we try for other commands we should get a error like permission denied



I am uisng visduo file and created a user and assigned a permission like



abhitest ALL=(ALL) /bin/ls


and I tried too abhitest ALL=/bin/ls



but its not working









share|improve this question













share|improve this question




share|improve this question








edited Mar 6 at 10:47









Archemar

18.9k93366




18.9k93366










asked Mar 6 at 10:30









Abhinai

1011




1011











  • This would allow user abhitest to run sudo -u <any other user> ls <any parameters>, i.e. the user would be able to run the ls command with any parameters as any user, including root. But it would have no effect at all for commands run as user abhitest: if you want that, you need to set up a restricted shell for that user.
    – telcoM
    Mar 6 at 10:37
















  • This would allow user abhitest to run sudo -u <any other user> ls <any parameters>, i.e. the user would be able to run the ls command with any parameters as any user, including root. But it would have no effect at all for commands run as user abhitest: if you want that, you need to set up a restricted shell for that user.
    – telcoM
    Mar 6 at 10:37















This would allow user abhitest to run sudo -u <any other user> ls <any parameters>, i.e. the user would be able to run the ls command with any parameters as any user, including root. But it would have no effect at all for commands run as user abhitest: if you want that, you need to set up a restricted shell for that user.
– telcoM
Mar 6 at 10:37




This would allow user abhitest to run sudo -u <any other user> ls <any parameters>, i.e. the user would be able to run the ls command with any parameters as any user, including root. But it would have no effect at all for commands run as user abhitest: if you want that, you need to set up a restricted shell for that user.
– telcoM
Mar 6 at 10:37










1 Answer
1






active

oldest

votes

















up vote
0
down vote













I supposed you refer to sudo mecanism (visudo is part of sudo)



with



abhitest ALL=(ALL) /bin/ls


you should be able to run, as abhitest



sudo /bin/ls 


  • you will be asked root abhitest's password. (this may or may not what you intend, assuming a real command)

try ti use in sudoers



abhitest ALL=(ALL) NOPASSWD: /bin/ls /some/secret/dir


you should be able, as abhitest to run



sudo /bin/ls /some/secret/dir


note that both



sudo ls /some/secret/dir
sudo /bin/ls /some/other/secret/dir


won't "work". In first case ls is not /bin/ls, in second case directories are different.






share|improve this answer






















  • @Kusalananda corrected, thanks.
    – Archemar
    Mar 6 at 11:58










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%2f428458%2frun-a-particular-method-using-sudo%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













I supposed you refer to sudo mecanism (visudo is part of sudo)



with



abhitest ALL=(ALL) /bin/ls


you should be able to run, as abhitest



sudo /bin/ls 


  • you will be asked root abhitest's password. (this may or may not what you intend, assuming a real command)

try ti use in sudoers



abhitest ALL=(ALL) NOPASSWD: /bin/ls /some/secret/dir


you should be able, as abhitest to run



sudo /bin/ls /some/secret/dir


note that both



sudo ls /some/secret/dir
sudo /bin/ls /some/other/secret/dir


won't "work". In first case ls is not /bin/ls, in second case directories are different.






share|improve this answer






















  • @Kusalananda corrected, thanks.
    – Archemar
    Mar 6 at 11:58














up vote
0
down vote













I supposed you refer to sudo mecanism (visudo is part of sudo)



with



abhitest ALL=(ALL) /bin/ls


you should be able to run, as abhitest



sudo /bin/ls 


  • you will be asked root abhitest's password. (this may or may not what you intend, assuming a real command)

try ti use in sudoers



abhitest ALL=(ALL) NOPASSWD: /bin/ls /some/secret/dir


you should be able, as abhitest to run



sudo /bin/ls /some/secret/dir


note that both



sudo ls /some/secret/dir
sudo /bin/ls /some/other/secret/dir


won't "work". In first case ls is not /bin/ls, in second case directories are different.






share|improve this answer






















  • @Kusalananda corrected, thanks.
    – Archemar
    Mar 6 at 11:58












up vote
0
down vote










up vote
0
down vote









I supposed you refer to sudo mecanism (visudo is part of sudo)



with



abhitest ALL=(ALL) /bin/ls


you should be able to run, as abhitest



sudo /bin/ls 


  • you will be asked root abhitest's password. (this may or may not what you intend, assuming a real command)

try ti use in sudoers



abhitest ALL=(ALL) NOPASSWD: /bin/ls /some/secret/dir


you should be able, as abhitest to run



sudo /bin/ls /some/secret/dir


note that both



sudo ls /some/secret/dir
sudo /bin/ls /some/other/secret/dir


won't "work". In first case ls is not /bin/ls, in second case directories are different.






share|improve this answer














I supposed you refer to sudo mecanism (visudo is part of sudo)



with



abhitest ALL=(ALL) /bin/ls


you should be able to run, as abhitest



sudo /bin/ls 


  • you will be asked root abhitest's password. (this may or may not what you intend, assuming a real command)

try ti use in sudoers



abhitest ALL=(ALL) NOPASSWD: /bin/ls /some/secret/dir


you should be able, as abhitest to run



sudo /bin/ls /some/secret/dir


note that both



sudo ls /some/secret/dir
sudo /bin/ls /some/other/secret/dir


won't "work". In first case ls is not /bin/ls, in second case directories are different.







share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 6 at 11:58

























answered Mar 6 at 10:46









Archemar

18.9k93366




18.9k93366











  • @Kusalananda corrected, thanks.
    – Archemar
    Mar 6 at 11:58
















  • @Kusalananda corrected, thanks.
    – Archemar
    Mar 6 at 11:58















@Kusalananda corrected, thanks.
– Archemar
Mar 6 at 11:58




@Kusalananda corrected, thanks.
– Archemar
Mar 6 at 11:58












 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f428458%2frun-a-particular-method-using-sudo%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