-2

I need to get a list of the Top 15 users (storage) in every mount. I am able to get the mount level information but I am not able to get the top users in every mount. I can see the nested folders in every mount.

For example; If I look to mount A, in this I could see folder A folder B folder C and again in each folder i,e Folder A i could more folders A1 A2. This is where my data sets/files are available.

Totally i have around 20 mount point (approx).

OS: Solaris

SAM
  • 1
  • 2
  • Welcome to the U&L SE. What is the criteria for selecting the 'top' users? Storage occupied? Number of files? Something else? Please add one or more examples. – Haxiel Jan 23 '19 at 07:07
  • Storage occupied by top users – SAM Jan 23 '19 at 07:11
  • Have you set up [quotas](https://docs.oracle.com/cd/E19253-01/817-0403/sysresquotas-97946/index.html) ? – Mark Plotnick Jan 23 '19 at 08:30
  • No we don't we are trying to make the report who are the top users in every mount and submit to IT team – SAM Jan 23 '19 at 08:31

1 Answers1

0
#!/bin/bash
for U in $(cut -d: -f1 /etc/passwd) ; do
    C=$(find / -type f -user $U -print0 | du -c --files0-from=- | tail -n 1 | cut -f1 )
    echo $C $U
done | sort -nr

This assumes local users and shows the size grouped by file owner which is as close to what you want as possible givin the ambiguity of the question.

https://serverfault.com/questions/632017/solaris-how-to-see-if-bash-is-installed

Solaris default install (user tools)

https://www.opencsw.org/packages/findutils/

user1133275
  • 5,488
  • 1
  • 19
  • 37
  • No its not working. – SAM Jan 23 '19 at 13:09
  • @SAM edit your question to show that you can get the list of users and a count for a sample user. Or error output. – user1133275 Jan 23 '19 at 13:16
  • 1st error is illegal operation C and it's coming out. – SAM Jan 23 '19 at 13:22
  • Both `find ... -print0` and `du ... --files0-from=-` are non-portable, GNU-specific extensions to the POSIX standard [`find`](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/find.html) and [`du`](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/du.html) utilities and not likely to work on a non-GNU OS such as Solaris. – Andrew Henle Jan 23 '19 at 14:57
  • oh! huge stuff ... smoke is out of my ears – SAM Jan 23 '19 at 15:03
  • @AndrewHenle thanks I added a link to https://unix.stackexchange.com/questions/66415/solaris-default-install-user-tools to make Solaris more compatible. – user1133275 Jan 23 '19 at 15:30
  • @SAM check the links for how to get gfind, gdu, etc. – user1133275 Jan 23 '19 at 15:38