Tuesday, April 9, 2013

useradd details

KNOW: Linux command line


Adding a user to Linux, or any Linux flavor, on the surface is easy enough.

useradd <username>

So the add the user Fred, you would do:

useradd fred

Then of course you need to add a password.

passwd fred

Done...well not really.  The problem is that a home directory, or any configuration scripts are absolutely absent.  We also don't have a group to work with.  In short, you have not much of anything but a username floating in the ether.

useradd -d /home/fred -m fred

Hmmm....that's different.

-d as this defines the home directory.  Standards are the username being the name of the home directory although there is no law supporting that option for sure.

-m will actually create the home directory.  Ya...go figure.

Skeleton files
/etc/skel  is a directory you should know about.  The /etc/skel is located at...OK you know right?  Anyway the point of that directory is to provide basic configuration files so that the user has something to work with.  This means of course you can create a set of files on your own and they will be copied to the user's home directory. 

IF you want, you can use -k and specify an alternate directory for the skeleton files.  It's up to you.


Just in case, please note that passwd <username> will add the password.

On some systems you can use :

adduser >username>

this is a much more automated and up-to-date idea so try it if you have support for it.





No comments:

Post a Comment