Useradd in Linux - Not copying any file from skel directory into it

15 July,2013 by Tom Collins

When creating a new local user on Linux  with the useradd  and the directory already exists , the following error \ warning message appears:

 

        useradd: warning: the home directory already exists.
        Not copying any file from skel directory into it.

 

 

If the directory  didn’t exist , the Linux useradd process  creates the directory and copies  the skel files  : .kshrc , .bashrc , .bash_profile and .bash_logout files into the user directory.

As a DBA it is not unusual to receive a server with directories already in place. In those situations a scripted approach is required to copy the skel files. A quick and dirty solution is to add the following line after the useradd sequence

 cp -r /etc/skel/. /<user_home_directpory>

An example sequence could be :

 

#add user : db2usr
echo "add user = db2usr"
useradd -g db2iadm1 -m db2usr -p 'dg8WM/S.o/bAE' -d /db2usr
chown db2usr /db2usr

#copy skel files 
cp -r /etc/skel/. /db2usr

 Read More

DB2 – Run script on Linux start

Linux Server OS information

DB2 Linux history command

Linux useradd not creating password




 

Author: Rambler(http://www.dba-db2.com)

Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been saved. Comments are moderated and will not appear until approved by the author. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on Useradd in Linux - Not copying any file from skel directory into it

Comments are moderated, and will not appear until the author has approved them.


dba-db2.com | DB2 Performance Tuning | DBA DB2:Everything | FAQ | Contact | Copyright