Last active
August 22, 2019 20:02
-
-
Save hridaydutta123/124d4e0701611f475cacbe0a4306975c to your computer and use it in GitHub Desktop.
Code to check per-user data usage in the system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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