Skip to content

Instantly share code, notes, and snippets.

@hridaydutta123
Last active August 22, 2019 20:02
Show Gist options
  • Save hridaydutta123/124d4e0701611f475cacbe0a4306975c to your computer and use it in GitHub Desktop.
Save hridaydutta123/124d4e0701611f475cacbe0a4306975c to your computer and use it in GitHub Desktop.
Code to check per-user data usage in the system
import sys
import os
# Get list of all users present in the system
allUsers = os.popen('cut -d: -f1 /etc/passwd').read().split('\n')[:-1]
for users in allUsers:
# Check if the home directory exists for the user
if os.path.exists('/home/' + str(users)):
# Print the current usage of the user
print(os.system('du -sh /home/' + str(users)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment