?
Solved

create default folder structure and ownership on user creation

Posted on 2016-09-20
5
Medium Priority
?
150 Views
Last Modified: 2016-10-26
Dear Experts,

I'm involved in a rather big project and I'm trying to automate as much of it as possible.
The problem I'm tackling right now consists of the following.
Assume I have a web interface that accepts a domain (for this example, we shall use banana.com)
the web interface then removes any dots, hyphens or any other special character from the domain name and passes the resulting string as a parameter to a bash script, which in turn invokes the useradd command.
so in this case, the command will be invoked as
useradd -m bananacom

Open in new window


This is all good and well and works fine.
I have also modified the /etc/skel folder to automatically create public_html and tmp folders in each users home directory.
Since we are using a very heavily customized NGINX version (Running on Centos 7) I need that everything under /home/$user/public_html (including the public html folder itself)
will always be set to 750 permissions, and $user:nginx ownership.

Meaning the as soon as I cerated the user, if I'd go to /home/bananacom
I'd see 2 folders in it:
/home/bananacom/public_html
/home/bananacom/tmp
Both will have drxw for bananacom, r-x for nginx and --- for other.
also, I need anything created under the public_html to defualt to those settings as well.
How would I go about creating such a thing?
0
Comment
Question by:David Sankovsky
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 30

Accepted Solution

by:
serialband earned 2000 total points
ID: 41809357
I believe you just need to set the default umask as 0027 for all users and they should be set correctly.
0
 
LVL 7

Author Comment

by:David Sankovsky
ID: 41810133
This will help with the permission Settings.
I still need to know how to set the default ownership.
Seeing as I need the skeleton to be created with nginx as the group
0
 
LVL 7

Expert Comment

by:huacat
ID: 41830135
# please create other folders first before below commands!
# set ownership command:
chown -R bananacom:nginx /home/bananacom/
# set permission command:
chmod -R 750 /home/bananacom/
0
 
LVL 7

Author Closing Comment

by:David Sankovsky
ID: 41856733
That worked better than expected Thank you
0
 
LVL 30

Expert Comment

by:serialband
ID: 41861423
Did you mean to give me all the points?  If you meant to split the points I can request attention and let you divide it properly.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
Hello EE, Today we will learn how to send all your network traffic through Tor which is useful to get around censorship and being tracked all together to a certain degree. This article assumes you will be using Linux, have a minimal knowledge of …
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question