Adding new users

Gerard Beekmans gerard at linuxfromscratch.org
Mon Mar 25 08:30:10 PST 2002


On Fri, Mar 22, 2002 at 08:30:04PM -0500, ira mendell wrote:
> I gather the long way is in order then;
>  1)  groupadd -g(gid) <newuser name>

You mean <group name> (just making sure).

>  2) useradd -m<newuser name>

You have to put a space between -m and the username. The username is not an
argument to the -m option. -m is a stand-alone option. It means so much as
"create the home dir, chown it to the user's user id and cp /etc/skel/* to
the home directory".

If you don't specify a -u userid, useradd will pick the next number that's
available.

You can set some defaults actually that will make you type less in the long
run.

First create the /etc/default directory, then run this:

useradd -D

it will show you the current default values. My output is as follows:
root at chroot:/home/gerard# useradd -D
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel


This means whenever I add a new user, his group id will automatically be
set to '100' (so I don' thave to pass -g anymore, unless I want to override
it), the shell is /bin/bash skel directory is /etc/skel and the base home
directory is /home. So all I do is useradd -m -u uid username

If you don't pick a userid, useradd will look in /etc/login.defs and look
for these lines:
UID_MIN                  1000
UID_MAX                 60000

It will now look in /etc/passwd and see if '1000' is free. If so,it'll try
1001, then 1002 until it finds an unused one, and will use it for the new
user.

-- 
Gerard Beekmans
www.linuxfromscratch.org

-*- If Linux doesn't have the solution, you have the wrong problem -*-
-- 
Unsubscribe: send email to listar at linuxfromscratch.org
and put 'unsubscribe lfs-support' in the subject header of the message



More information about the lfs-support mailing list