December 2024
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

Categories

December 2024
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

useradd Not copying any file from skel directory into it.

Useradd in Linux – Not copying any file from skel directory into it
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 :

groupadd skprod

useradd -m -s /bin/bash -g skprod  -d /data/app/sit01  sit01
chown -R sit01:skprod /data/app/sit01
cp -r /etc/skel/. /data/app/-sit01

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>