Deleting user doesn't remove homedir

When a new user is created in Plinth (System/Users and Groups), a directory /home/[username] is created for it. If you delete the user in Plinth, that directory doesn’t get removed. Is that intended/desired for some reason? The following example comes from a container.

Before creating user aaa:

fbx@freedombox:~$ ls -al /home
total 16
drwxr-xr-x 1 root  root    16 Apr 25 19:32 .
drwxr-xr-x 1 root  root   256 Apr 25 19:31 ..
drwxr-xr-x 1 admin users   54 Mar 16 01:58 admin
drwx------ 1 fbx   plinth 134 Apr 25 19:40 fbx

After creating user aaa:

fbx@freedombox:~$ ls -al /home
total 16
drwxr-xr-x 1 root  root    22 Apr 25 19:41 .
drwxr-xr-x 1 root  root   256 Apr 25 19:31 ..
drwxr-xr-x 1 aaa   users   54 Mar 16 01:58 aaa
drwxr-xr-x 1 admin users   54 Mar 16 01:58 admin
drwx------ 1 fbx   plinth 134 Apr 25 19:40 fbx

After deleting user aaa:

fbx@freedombox:~$ ls -al /home
total 16
drwxr-xr-x 1 root  root    22 Apr 25 19:41 .
drwxr-xr-x 1 root  root   256 Apr 25 19:31 ..
drwxr-xr-x 1 10002 users   54 Mar 16 01:58 aaa
drwxr-xr-x 1 admin users   54 Mar 16 01:58 admin
drwx------ 1 fbx   plinth 134 Apr 25 19:40 fbx

Hi @lifeform

I believe this may be intentional and “good practice” in server administration (just my assumption).

I know from my company that when user accounts are removed, their data doesnt get deleted (in case the same user returns in the future or if the corporation needs access to their files).

Retaining the homedir could be useful on systems not dedicated to FreedomBox or for advanced users, but it doesn’t further the design goal of allowing FreedomBox to be administered through Plinth by users who may not even know what a homedir is. Adding/Deleting users seems like core functionality that shouldn’t leave behind orphaned data.

One solution to accommodate both approaches might be to remove the homedir by default, but on the Delete confirmation page where the user is asked “Delete user [username] permanently?”, to add a checkbox that would cause the homedir not to be deleted.

I thought it could have been an oversight not to remove the homedir because it also doesn’t get renamed when a user gets renamed.

Entry in /home after creation of user bbb:

drwxr-xr-x 1 bbb users 54 Mar 16 01:58 bbb

Entry in /home after renaming bbb to ccc in System/Users and Groups:

drwxr-xr-x 1 ccc users 62 Apr 27 08:52 bbb

1 Like

@lifeform maybe post this as an issue on fbx git?

userdel manpage indicates that home directory removal is optional and requires -r argument. FreedomBox is doing the same as userdel with no arguments. That is probably the way to go unless they add options to user delete dialog in FreedomBox.

1 Like