To perform disk usage monitoring of users on a UNIX system, you will, first of all, need to determine the home directories of the users. You might ask, “Aren’t all the user home directories found under /home?”. Well, typically yes, but it’s not always true.
There are a couple of ways to determine the home directory of an user. I know of two methods at the moment.
- Extract the home directory field from /etc/passwd
12root@anfield:~# grep ibrahim /etc/passwd | awk -F":" '{ print $6 }'/users/ibrahim
- Use Tilde Expansion – this is useful when the user management/authentication is done via NIS or LDAP.
12root@anfield:~# echo ~ibrahim/users/ibrahim