LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   useradd command used for specific home directory but dont get full access (https://www.linuxquestions.org/questions/linux-newbie-8/useradd-command-used-for-specific-home-directory-but-dont-get-full-access-4175544809/)

johnmaxwell 06-08-2015 08:45 AM

useradd command used for specific home directory but dont get full access
 
useradd -c "the body holiday dev user" -m -d /var/www/html/thebodyholiday/ -N -G apache tbholiday

With this command i wanted the tbholiday user to directly login to /var/www/html/thebodyholiday/ directory, by being a member in the apache group.

All i want is that all the files and folders of that dirtory should belong to the user tbholiday and group apache by default, with 775 permission and the user tbholiday should be able to run any command in that directory /var/www/html/thebodyholiday/ like a root user.

but all the files dont have this permission setup, i have to run chown -R tbholiday:apache thebodyholiday/ chmod -R 0775 thebodyholiday/ these two command every two to thrww days when new files or folder is created.

And user tbholiday can not update the wordpress plugin or any updates automatically, it ask for root permission, so for the time being i ran visudo command and added tbholiday = All(All:All)All so now it do ask for password, but the user got full access like root user, i dont want this. I just want the user tbholiday to run any command or update or anything in that directoy, but not any other place.

Please help. Urgent. And thanks to you all.

dmunkz 06-08-2015 11:02 AM

try this with useradd
 
Hello,

Can you try the below, substituting your user name in place.


Code:


userdel YOUR_USER && useradd -g YOUR_GROUP -d YOUR_DIRECTORY YOUR_USER

In the above :
YOUR_USER : an ls -al against your web directory should look like this : YOUR_USER(owner) YOUR_GROUP(the group) PERMS (I typically think 755 for doc roots.).

It sounds like your permissions are wonked up. If for example, /var/www/site/bin had the wrong permissions OR any thing along the path, you would see issues like that.

suicidaleggroll 06-08-2015 11:06 AM

useradd does NOT change the permissions in the intended "home" directory to automatically belong to the user you add. Nor does having a user with some directory as their home force ALL files written to that directory by ANY user to be automatically changed to user who has that as their home directory.

That's not how permissions work. Users do not automatically "inherit" any and all files that are written to their home directory by anybody. File permissions are file permissions, it makes no difference where somebody's "home" is.


All times are GMT -5. The time now is 06:14 PM.