Disk Yönetimi

Find Disk Space Used by Specific User Linux

Find Disk Space Used by Specific User Linux
Once in a while, you may need to take stock of the files owned by a specific user in a Linux system with several login users. This comes in handy when you want to free up some space and prevent your hard drive from getting depleted.  This is especially if some users have long since stopped using the system and their accounts have been disabled. So, how do you evaluate the disk space taken up by a specific user? Let's find out.

Count the total disk space used by a particular user

To obtain the disk space used by a specific user, use the find command syntax as follows:

$ find /path/to/directory/ -user username_whose_files_are_to_be_counted -type f -printf "%s\n" | awk 't+=$1ENDprint t'

Let's break down this command syntax:

The first section -  find /path/to/directory/ - performs a search in the specified directory path.

The second section - -user username_whose_files_are_to_be_counted - restricts the search operation to a specific user only.

The third section - -type f  -  indicates that we are only searching for files and not directories. Empty directories usually take up 4kb, which is negligible.

The last section - -printf “%s\n” | awk 't+=$1ENDprint t'

Prints out the size of the files.

Suppose you want to find out the disk usage of a user called james in the home directory. The command will be.

$ find /home  -user james -type f -printf "%s\n" | awk 't+=$1ENDprint t'

If you are inside a directory, you can view the disk usage using the command shown,

$ find . -type f -printf "%u %s\n" \ | awk 'user[$1]+=$2; ENDfor(i in user) print i,user[i]'

For example, I will navigate to the Downloads directory, located in my home directory, and check the disk space used by specific users. The output clearly displays the disk space summary where two users have files saved in the current directory, which is the /home/james/Downloads directory.

And there you go. We have successfully seen how you can find the disk space by specific users in Linux.

En son OpenRA Strateji Oyununu Ubuntu Linux'a yükleyin
OpenRA, klasik Command & Conquer: Red Alert gibi erken Westwood oyunlarını yeniden yaratan bir Libre/Free Gerçek Zamanlı Strateji oyun motorudur. Dağı...
Gamecube & Wii için en yeni Dolphin Emulator'ı Linux'a yükleyin
Dolphin Emulator, seçtiğiniz Gamecube & Wii oyunlarını Linux Kişisel Bilgisayarlarda (PC) oynamanıza izin verir. Ücretsiz olarak kullanılabilen ve aç...
Linux'ta GameConqueror Cheat Engine Nasıl Kullanılır
Makale, Linux'ta GameConqueror hile motorunu kullanma hakkında bir kılavuzu kapsar. Windows'ta oyun oynayan birçok kullanıcı, oyun deneyimini geliştir...