3

My motives:

I want to create deployment script which prepare all system with just 1 click, and although learn Linux this way. So I don't want to use interactive utils like adduser (all interaction info I put in some settings.txt).

My system:

Debian 8.2 (jessie)

I want:

Create user account with home directory and default folders inside. Like adduser do but with useradd.

My problem:

There is paragraph in man userradd:

   -m, --create-home
       Create the user's home directory if it does not exist. The files and directories contained in the
       skeleton directory (which can be defined with the -k option) will be copied to the home directory.

I looked in /etc/adduser.conf to find the value of SKEL variable for adduser. And it is /etc/skel.

But after I run some useradd -m myuser -k /etc/skel, I've got empty /home/myuser directory.

Update 1

After I created some additional file, it alsought copied to the new user home directory (with 3 hidden files). So it means that /etc/skel doesn't impact on such folders as: Desktop, Downloads, etc. But in this case what does?

  • 2
    The directories you are referring to are part of the xdg-user-dirs I think, and are specific to "desktop" environments: IIRC they are created by the system when the user first instantiates an appropriate Xsession, based on the templates in /etc/xdg/user-dirs.defaults – steeldriver Oct 11 '15 at 13:54
1

For me , by default, the /etc/skel contains just 3 hidden files, .bash_logout , .bashrc and .profile, which can be displayed with ls -a.
Your command should work, have you checked the content of your /etc/skel directory ?

  • I although found 3 hidden files inside /etc/skel. (post updated) – Alex Silkovsky Oct 11 '15 at 11:19
  • You have to create the folders/files in /etc/skel . For example, I created /etc/skel/Desktop/test.sh and for the new user, the folder /home/myuser/Desktop was created containing the test.sh file . – mazs Oct 11 '15 at 11:33
1

When a new home directory is created by adduser or useradd, the home directory is populated with the contents of /etc/skel (the "skeletal home directory", see man adduser and/or man useradd). This directory contains the initial dot-files, like .bashrc etc., that all users get. The Desktop etc. directories are usually not part of the contents of she skeletal home directory since a user may not even want to run a desktop environment (or one that uses those directories).

These directories are created when the user logs in and starts a graphical desktop environment.

Would you want these extra directories (or any other file or directory) to be part of the skeletal home directory, then create them in /etc/skel, assuming the user's graphical desktop environment does not have issues with these directories already existing (I don't use Linux-like desktops, so I don't know).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.