Delete Hue Users
Luke Hebert
- 2 minutes read - 413 wordsHue does not ship with a built-in option to delete user accounts from the web UI. If you need to remove stale or orphaned accounts, the only practical path is to drop into the Hue Django shell and call the ORM delete method directly. The steps below show both a single-user delete and a batch delete.
This is not a supported Cloudera process. It has not been fully tested by Cloudera support, and using it may leave the Hue database in an inconsistent state. Take a full backup of the Hue database before proceeding.
Prerequisites
- You have root or sudo access to the Hue server node.
- You know the Hue database password (the value of
HUE_DATABASE_PASSWORD). - The Hue server role is running (the process directory must exist).
Single-User Delete
The following command locates the active Hue server process directory, opens the Django shell, and deletes one user by username:
export HUE_CONF_DIR="/var/run/cloudera-scm-agent/process/$(ls -1 /var/run/cloudera-scm-agent/process | grep HUE_SERVER | sort -n | tail -1)"
HUE_IGNORE_PASSWORD_SCRIPT_ERRORS=1
HUE_DATABASE_PASSWORD="<huedbpass>"
/opt/cloudera/parcels/CDH/lib/hue/build/env/bin/hue shell << EOF
from django.contrib.auth.models import User
user = User.objects.get(username="tuser1")
user.delete()
EOFThe blank line before EOF is required. Without it the heredoc will not terminate cleanly and the shell will hang.
Batch Delete
If you need to remove several users at once, use a list and the filter().delete() pattern:
export HUE_CONF_DIR="/var/run/cloudera-scm-agent/process/$(ls -1 /var/run/cloudera-scm-agent/process | grep HUE_SERVER | sort -n | tail -1)"
HUE_IGNORE_PASSWORD_SCRIPT_ERRORS=1
HUE_DATABASE_PASSWORD="<huedbpass>"
/opt/cloudera/parcels/CDH/lib/hue/build/env/bin/hue shellOnce the interactive Python prompt appears, run:
from django.contrib.auth.models import User
usernames = ['userabc', 'userdef']
User.objects.filter(username__in=usernames).delete()This returns a tuple showing how many objects were deleted and a mapping of model names to counts, for example (2, {'auth.User': 2}).
Verifying the Deletion
After running either command, log in to the Hue web UI and confirm the user no longer appears in the user list. You can also re-run the shell and query:
User.objects.filter(username="tuser1").count()A return value of 0 confirms the account is gone.
Things to Keep in Mind
- Hue stores its user data in its own database (MySQL, PostgreSQL, or SQLite depending on your deployment). Deleting a user here does not remove the corresponding LDAP or Active Directory account.
- If the user had saved queries, notebooks, or dashboard items, those rows may remain in the database as orphans. A DBA can clean them up separately if needed.
- Because this is an unsupported path, Cloudera support may not be able to assist if the database ends up in an unexpected state. Always snapshot the database first.