Operating System - HP-UX
1822001 Members
4107 Online
109639 Solutions
New Discussion юеВ

Creating Home Directories without -m -d option on Useradd command.

 
Naveen M
Advisor

Creating Home Directories without -m -d option on Useradd command.

While adding a user, we use the following command to create home directory for that user.

#useradd -m -d /home/

But, how can a user directory be created everytime when I run useradd command without specifying -m -d option?

Thanks in advance.
6 REPLIES 6
Scp_1
Advisor

Re: Creating Home Directories without -m -d option on Useradd command.

I dont think its possible.
Yogeeraj_1
Honored Contributor

Re: Creating Home Directories without -m -d option on Useradd command.

hi,

why dont you create a custom script to perform that same?

e.g.
#useradd.sh yogeeraj

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Naveen M
Advisor

Re: Creating Home Directories without -m -d option on Useradd command.

Dont have much experience with scripting. Please share if u know a script for this.
Thanks
Naveen M
Advisor

Re: Creating Home Directories without -m -d option on Useradd command.

Got a workaround for this.

#i=
#alias adduser='useradd -m -d /home/$i $i'
#adduser

#i=
#adduser

and so on.

Thanks all for your help.
Dennis Handly
Acclaimed Contributor

Re: Creating Home Directories without -m -d option on Useradd command.

>Got a workaround for this.
#i=

You don't want to use alises, functions at least let you have a parm. But better to write a script:
#!/sbin/sh
# Usage: adduser ...
for user in $*; do
useradd -m -d /home/$user $user
done

If you are happy with the answers you got, please read the following about assigning points:
http://forums.itrc.hp.com/service/forums/helptips.do?#33
Naveen M
Advisor

Re: Creating Home Directories without -m -d option on Useradd command.

Thanks everyone.