LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 12-26-2014, 11:06 AM   #1
slufoot80
Member
 
Registered: Nov 2011
Posts: 69

Rep: Reputation: Disabled
Cool Sudo question specific commands on specific directories


Ok what I want to do is allow a user to run the following commands on specific directories but these are root commands

Code:
unlink /source/directory
Code:
ln -s /source/directory /destination/directory
Code:
mv /source/directory to /destination/directory.old
 
Old 12-26-2014, 12:42 PM   #2
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
Make the user owner of parent directory.
 
Old 12-26-2014, 02:19 PM   #3
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 4,542

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
You can set up sudoers so that the user is allowed to run those commands with exactly those arguments.
 
Old 12-29-2014, 08:40 AM   #4
slufoot80
Member
 
Registered: Nov 2011
Posts: 69

Original Poster
Rep: Reputation: Disabled
Smile sudo permissions for specific commands

Ok what I want to do is give a user permissions or the ability to run the command below for only the specific command and location nothing else on a case by case bases, i.e..

Code:
unlink /forms/directory
Then
Code:
ln -s /new/location/ to /forms/directory
Then
Code:
mv /old/location to /old/location.old
and only for the above locations and nothing more these locations are owned by other users and the /old/ directory is owned by root, but /old/"location" is owned by the owner. but the links are owned by root
 
Old 12-29-2014, 08:57 AM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594
Note 'unlink' doesn't automagically mean being able to delete directories. Also note this seems to be a continuation of https://www.linuxquestions.org/quest...es-4175529280/ so I'll be merging threads.

As for your question: first create a shell script containing the above commands, then make it executable (0755) and place it in say /usr/local/sbin/, then edit (visudo) /etc/sudoers to allow that user to execute the script as root user. See 'man sudoers' for examples. If unsure post your script plus your modified /etc/sudoers.
 
Old 12-30-2014, 08:53 AM   #6
slufoot80
Member
 
Registered: Nov 2011
Posts: 69

Original Poster
Rep: Reputation: Disabled
replay

Quote:
Originally Posted by unSpawn View Post
Note 'unlink' doesn't automagically mean being able to delete directories. Also note this seems to be a continuation of https://www.linuxquestions.org/quest...es-4175529280/ so I'll be merging threads.

As for your question: first create a shell script containing the above commands, then make it executable (0755) and place it in say /usr/local/sbin/, then edit (visudo) /etc/sudoers to allow that user to execute the script as root user. See 'man sudoers' for examples. If unsure post your script plus your modified /etc/sudoers.
even if I put it in a script they still doesn't mean they have permissions
 
Old 12-30-2014, 08:57 AM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594
Quote:
Originally Posted by slufoot80 View Post
even if I put it in a script they still doesn't mean they have permissions
If this is a statement then I wonder who it is aimed at?
Elif this is a question then I do not comprehend it.
 
  


Reply

Tags
sudo


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to move seleted directories to specific directories by putting condition VijayB Linux - Newbie 3 07-05-2014 03:31 PM
[SOLVED] Sudo access to specific files/services whositwhatnow Linux - Security 5 08-02-2012 10:39 AM
Setting up user to use sudo for specific commands kreed Linux - Newbie 6 05-16-2011 04:43 PM
[SOLVED] specific file name renaming in all sub directories Jack_R Linux - Newbie 15 04-07-2011 02:35 AM
using find to only search specific directories isaaclw Linux - Software 5 01-09-2010 08:01 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 11:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration