Adding users - what creates their default subdirectories? (Suse 11.4)

Can anyone tell me what process creates the user directories ~/Documents, ~/Downloads, ~/Public etc?

They are not present in the structure of /etc/skel, and they do not appear until the user logs in to any graphical environment for the first time. I tried it with KDE, LXDE and Icewm. In each case the same set of directories were created. I’ve searched the scripts in /etc/X11, without success.

There are packages “xdg-user-dirs” and “xdg-user-dirs-gtk” which provide the logic behind this. Try “rpm -ql xdg-user-dirs{,-gtk}” to find some of the relevant files. There are two obvious places from where this program is called:

  • /etc/xdg/autostart/user-dirs-update-gtk.desktop: On my machine this is executed in GNOME, XFCE and LXDE.
  • /etc/X11/xinit/xinitrc.d/xdg-user-dirs.sh. Maybe this is only called when an Xserver is started by the user, but I’m not sure. You write that these dirs also appear if you use IceWM, so maybe it gets called whenever someone logs in from vt7.

You find the configuration of this (including non-localized directory names) in /etc/xdg/user-dirs.* .
If you don’t like the default setting for a specific user account, you can change it by creating ~/.config/user-dirs.dirs. That’s how I do it.
– Y

AFAIK, the tool useradd is used internally by YaST, thus read

man useradd

and there you see that /etc/skel is used as a skeleton for polupalting a user’s home directory aty user creation.

It depends if the xinitrc or Xsession script starting the X session runs this script or not:

# run all system xinitrc shell scripts.

if  -d /etc/X11/xinit/xinitrc.d ]; then
    for i in /etc/X11/xinit/xinitrc.d/* ; do
        echo "Loading xinit script $i"
        if  -x "$i" -a ! -d "$i" ]; then
	    . "$i"
        fi
    done
fi

As you can see in this example, removing the executable bit will prevent a script from beeing sourced.

These directories are not included in /etc/skel and not created by useradd.
See here: Man Page for xdg-user-dirs-update (OpenSolaris Section 1) - The UNIX and Linux Forums
The manpage in this link is for OpenSolaris, but it’s the same under Linux. It’s a FreeDesktop (XDG) thing.

icewm-session (not icewm) is partially XDG compatible.

On 2012-08-02 12:56, hcvv wrote:
>
> AFAIK, the tool useradd is used internally by YaST, thus read
>
> Code:
> --------------------
> man useradd
> --------------------
>
> and there you see that /etc/skel is used as a skeleton for polupalting
> a user’s home directory aty user creation.

But ~/Documents is not there, for example. Or ~/Desktop.


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

I don’t know in general.

In my case, they are automatically created for the user I give during install. I later create two additional users with “vipw”, and nothing is created for them. But they have home directories from earlier use (earlier versions of linux).

For those two additional users, “Documents”, “Desktop”, “Public” and several others are created by KDE4 when that user first logs in. I presume other desktop environments do the same.

If I don’t want those directories, I can then delete them and avoid any X desktop login for that user.

Who is that going to help to learn that you don’t know (in general)? Btw the question has been answered in the other posts. Just read them and you will know!

I stand corrected. And the OP allready said that in it’s first post. It is something added when using a GUI.

Thank you all for your contributions. In particular,

led me to the complete answer.