Crouzilles
Crouzilles

Reputation: 813

FInd largest files and directories for a specific user

I am new to linux and I would like to find the 10 largest files and directories belonging to a specific user, how should I go about doing this?

Thank you Crouz

Upvotes: 1

Views: 805

Answers (1)

vszurma
vszurma

Reputation: 273

directories:

du $usershome | sort -nr | head -n10

files:

find $usershome -exec stat --format '%s %n' \{\} \; | sort -nr | head -n10

edit: by owner

directories:

find / -user $username -type d -exec du --max-depth=1 \{\} \; | sort -nr | head -n10

files:

find / -user $username -type f -exec stat --format '%s %n' \{\} \; | sort -nr | head -n10

Upvotes: 2

Related Questions