LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Add directory by the root to a new user (script) (https://www.linuxquestions.org/questions/programming-9/add-directory-by-the-root-to-a-new-user-script-4175444594/)

FirstStepInLX 01-07-2013 09:12 PM

Add directory by the root to a new user (script)
 
I'm working on a script which create users automatically with some parameters. So i would like to ask how can i create repertories in the home directory of the new user

+ the script is used with sudo
# ./sudo name_script

My syntax is:

# after the creation of the new_user i tried this syntax:

mkdir new_directory

# when i check if the new_directory has been created
# i find it in the current user not in the new_user.

#I also tried this syntax,but the new_directory doesn't exist too.
#I supposed that now i'm in the new_user

su -l new_user

mkdir new_directory

#The creation of users woks good.

EricTRA 01-08-2013 12:20 AM

Hello and welcome to LinuxQuestions,

Please don't post your question in multiple forums. Stick to one thread per problem to keep focus on it. I'm reporting this one for closure since it's a duplicate of this one.

Kind regards,

Eric

-------------
Disregard, mods closed your other thread while I was posting in it, so I'll stick to this one.

NevemTeve 01-08-2013 03:36 AM

1. google for /etc/skeleton
2. use this:
Code:

su -c 'mkdir ~/dir' newuser


All times are GMT -5. The time now is 10:29 PM.