Monday, July 16, 2007

TIP: auto create mail spool when adding user

The linux command "useradd" creates a new user or update default new user information from your linux box.

By default behaviour, useradd does many other default things besides from creating the user account.

Man says:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When invoked without the -D option, the useradd command creates a new user account using the values specified on the command line and the default values from the system. Depending on command line options, the useradd command will update system files and may also create the new user’s home directory and copy initial files. The version provided with Red Hat Linux will create a group for each user added to the system by default .
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

One thing that useradd does not do is create var mail spool during the creation or adding of new user accounts. Changing this behavious is as easy as:

# cd /etc/default

# cat useradd

You will then see similar lines like

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`

Simply append the below line:

CREATE_MAIL_SPOOL=yes

and save.

TO TEST:

# useradd -d /home/vertito vertito
# cd /var/spool/mail
# ls -la vertito
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-rw-rw---- 1 g mail 0 2007-07-16 16:24 vertito
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You'll now have a zero-sized (0) mail spool file owned by the newly created user.

Hope this helps.


CREATE_MAIL_SPOOL

0 comments:

Sign up for PayPal and start accepting credit card payments instantly.
ILoveTux - howtos and news | About | Contact | TOS | Policy