LXD, the system container manager, has become a popular choice for many developers and sysadmins due to its lightweight nature and ease of use. However, like any software, it can sometimes present challenges. One such challenge that has been identified in LXD version 5.18, especially in multi-user environments, is the difficulty in properly deleting a user. This post will delve into this issue and provide a comprehensive solution.

The Problem

In LXD 5.18 multi-user setups, when attempting to delete a user from the system, not all references to that user and their associated UID are removed. This lingering data can cause conflicts, especially if you try to recreate a user with the same name or if the system tries to reuse the UID for a new user.

The Solution

To ensure a clean removal of a user and all their associated LXD resources, follow the steps below:

  1. Delete the User from the System:
    • First, retrieve the user’s UID with:
      DELUID = id <username>
    • Then, delete the user and their home directory:
      sudo deluser <username> --remove-home
  2. Clean Up LXD Resources:
    • Switch to the user’s LXD project (assuming each user has their own LXD project based on their UID):
      lxc project switch user-${DELUID}
    • Delete all instances (containers, VMs) associated with the user’s project:
      lxc list
      lxc delete <instances> --force
    • Remove all images tied to that user:
      lxc image list
      lxc image delete <FINGERPRINT>
    • Finally, delete the user’s LXD project:
      lxc project delete user-${DELUID}
  3. Remove LXD Network Resources:
    • If each user has their own LXD bridge network, remove it:
      lxc network list
      lxc network delete lxdbr-${DELUID}
  4. Revoke Trust:
    • List all trusted certificates:
      lxc config trust list
    • Delete the certificate associated with the user:
      lxc config trust delete lxd-user-${DELUID}
  5. Clean Up User’s LXD Configuration:
    • Ensure all user-specific LXD configurations and data are removed:
      sudo ls -al /var/snap/lxd/common/lxd-user/users
      sudo rm -rf /var/snap/lxd/common/lxd-user/users/${DELUID}
  6. Add a New User:
    • With all references to the old user cleaned up, you can now safely add a new user to the system:
      sudo adduser <new_user>
      sudo adduser <new_user> users


While LXD offers a powerful platform for container management, it’s essential to be aware of potential pitfalls and know how to navigate them. This guide provides a solution to a specific issue in LXD 5.18, ensuring a smooth user management experience in multi-user environments. Always remember to backup any crucial data before performing such operations and double-check each command to avoid unintended data loss.