Difference between revisions of "Configuring for Adding Users"

From CBLFS
Jump to navigationJump to search
(I updated the users group number to match CLFS.)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
This will make sure each user is set up appropriately with the correct group memberships, as well as copy the appropriate template of files from /etc/skel to each new user's home directory.
 
This will make sure each user is set up appropriately with the correct group memberships, as well as copy the appropriate template of files from /etc/skel to each new user's home directory.
  
Create a base '''/etc/default/useradd''':
+
Modify the '''/etc/default/useradd''' that shadow installed:
  
  cat > /etc/default/useradd << "EOF"
+
  useradd -D -b /home
GROUP=1000
+
  sed -i "/CREATE_MAIL_SPOOL/s/yes/no/" /etc/default/useradd
HOME=/home
 
  INACTIVE=-1
 
EXPIRE=
 
SHELL=
 
SKEL=/etc/skel
 
EOF
 
  
 
Add the default group that new users will become automatic members of:
 
Add the default group that new users will become automatic members of:
Line 38: Line 32:
 
  chmod +x /usr/sbin/adduser
 
  chmod +x /usr/sbin/adduser
  
Note: The above script adds new users to the '''users''' and '''audio''' groups.  If you are in a hardened security environment, simply omit creating the script at all.
+
{{Note|The above script adds new users to the '''users''' and '''audio''' groups.  If you are in a hardened security environment, simply omit creating the script at all.}}

Latest revision as of 15:26, 1 January 2008

This will make sure each user is set up appropriately with the correct group memberships, as well as copy the appropriate template of files from /etc/skel to each new user's home directory.

Modify the /etc/default/useradd that shadow installed:

useradd -D -b /home
sed -i "/CREATE_MAIL_SPOOL/s/yes/no/" /etc/default/useradd

Add the default group that new users will become automatic members of:

groupadd -g 1000 users

Complete the EXPIRE and SHELL entries of /etc/default/useradd based on the current environment:

/usr/sbin/useradd -D -s/bin/bash

Create the /etc/skel directory:

mkdir /etc/skel

Copy any personal settings you want to be applied upon user creation in this directory.


Create the adduser script and give it executable permissions:

cat > /usr/sbin/adduser << "EOF"
#!/bin/sh
useradd -m $1
passwd $1
gpasswd -a $1 users
gpasswd -a $1 audio
EOF
chmod +x /usr/sbin/adduser
Caution.png

Note

The above script adds new users to the users and audio groups. If you are in a hardened security environment, simply omit creating the script at all.