Techolac - Computer Technology News
  • Home
  • Internet
  • Business
  • Computers
  • Gadgets
  • Lifestyle
  • Phones
  • Travel
  • Tech
  • More
    • Automotive
    • Education
    • Entertainment
    • Health
    • SEO
    • Linux
    • WordPress
    • Home Improvement
    • How to
    • Games
No Result
View All Result
  • Home
  • Internet
  • Business
  • Computers
  • Gadgets
  • Lifestyle
  • Phones
  • Travel
  • Tech
  • More
    • Automotive
    • Education
    • Entertainment
    • Health
    • SEO
    • Linux
    • WordPress
    • Home Improvement
    • How to
    • Games
No Result
View All Result
Techolac - Computer Technology News
No Result
View All Result
Home Linux

Linux find largest file in directory recursively using find/du

by Editorial Staff
April 19, 2024
in Linux
Reading Time: 3 mins read

I have 500GB SSD installed on my Linux server. My web server is running out of the disk space. I need to find a biggest or largest file concerning file size on the disk. How do I find largest file in a directory recursively using the find command?

To find a big file concerning file size on disk is easy task if you know how to use the find, du and other command. The du command used to estimate file space usage on Linux system. The output of du passed on to the sort and head command using shell pipes. Let us see how to find largest file in Linux server using various commands.

Table of Contents
Linux find largest file in directory recursively using find
Linux find a biggest files in /
Linux find large files quickly with bash alias
Finding largest file recursively on Linux bash shell using find
Great! I found the largest files on my disk. What next?>
Conclusion

Linux find largest file in directory recursively using find

The procedure to find largest files including directories in Linux is as follows:

  1. Open the terminal application
  2. Login as root user using the sudo -i command
  3. Type du -a /dir/ | sort -n -r | head -n 20
  4. du will estimate file space usage
  5. sort will sort out the output of du command
  6. head will only show top 20 largest file in /dir/

Linux find a biggest files in /

Run the command:
$ sudo du -a /dir/ | sort -n -r | head -n 20
OR
$ sudo du -a / 2>/dev/null | sort -n -r | head -n 20
Linux find largest file in directory recursively using du and friends

Linux find large files quickly with bash alias

One can hunt down disk space hogs with ducks bash shell alias

## shell alias ##  
alias ducks='du -cks * | sort -rn | head'
### run it ###
ducks

## shell alias ##
alias ducks=’du -cks * | sort -rn | head’
### run it ###
ducks

How To Find Largest Top 10 Files and Directories On Linux / UNIX / BSD
How To Find Largest Top 10 Files and Directories On Linux / UNIX / BSD

Finding largest file recursively on Linux bash shell using find

One can only list files and skip the directories with the find command instead of using the du command, sort command and NA command combination:
$ sudo find / -type f -printf "%st%pn" | sort -n | tail -1
$ find $HOME -type f -printf '%s %pn' | sort -nr | head -10

Sample outputs:

295599646	/home/vivek/backups/lnxpcs-master.zip
302654548	/home/vivek/backups/books/pdfs/unit443.wmv
313499710	/home/vivek/backups/books/pdfs/magzine.rar
340414464	/home/vivek/.local/share/baloo/index
346359808	/home/vivek/isoimages/VMware-VMvisor-Installer-6.7.0-8169922.x86_64.iso
352256000	/home/vivek/install63.iso
830054400	/home/vivek/linux/linux-4.18.8.tar
1014864333	/home/vivek/backups/corpapp/vsnl_9.5.2_E_21_Linux.tar.gz
1216380038	/home/vivek/backups/books/full.edition.tar.gz
1787822080	/home/vivek/Fedora-Workstation-Live-x86_64-28-1.1.iso

295599646 /home/vivek/backups/lnxpcs-master.zip
302654548 /home/vivek/backups/books/pdfs/unit443.wmv
313499710 /home/vivek/backups/books/pdfs/magzine.rar
340414464 /home/vivek/.local/share/baloo/index
346359808 /home/vivek/isoimages/VMware-VMvisor-Installer-6.7.0-8169922.x86_64.iso
352256000 /home/vivek/install63.iso
830054400 /home/vivek/linux/linux-4.18.8.tar
1014864333 /home/vivek/backups/corpapp/vsnl_9.5.2_E_21_Linux.tar.gz
1216380038 /home/vivek/backups/books/full.edition.tar.gz
1787822080 /home/vivek/Fedora-Workstation-Live-x86_64-28-1.1.iso

Great! I found the largest files on my disk. What next?>

Depend upon file/dir type you can either move or delete the file. For example, you cannot remove or move the Linux kernel or diver directories. To delete unwanted file on Linux use the rm command:
rm -i -v /path/to/file
To get rid of all files and its sub-directories recursively use following command:
rm -rf /path/to/folderName
To move file to a usb pen mounted at /mnt/usb/, run the mv command:
mv /path/to/large/file/ /mnt/usb/

Conclusion

You just learned how to search, find and list largest or biggest directories/files in Linux using the combination of du/find and other commands. For more info see this page or man pages of du and find commands:
man du
man find
man sort
man head
man tail

[ad_2]

Related Posts

Apache, MySQL Performance

How to Optimize Apache, MySQL Performance for 1GB RAM VPS Centos/RHEL

April 7, 2024
Top 5 MySQL Performance Tuning Tips

Top 5 MySQL Performance Tuning Tips

January 25, 2023

Top Commands to Check the Running Processes in Linux

May 27, 2022

4 Tips to Prevent and Troubleshoot the ImagePullBackOff Kubernetes Error

March 30, 2022

How Common Signals are Used in Kubernetes Pod Management

November 20, 2021

How to Transfer Windows 10 to SSD?

April 14, 2022

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Articles

  • Biometric Banking: Why Your Face, Fingerprint, and Voice Are the New PIN
  • The Revolution in Telecommunications: How technology is changing connections
  • Understanding the Differences: BACS vs CHAPS Payment Systems Explained
  • Why CSPM Is the Unsung Hero of Enterprise Cloud Security
  • The New Face of Antivirus: Smarter, Faster, and Built for 2025 Threats
  • What are The Responsibilities of your tax preparer?
  • Best 10 Cryptocurrency Exchange Development Companies 2025

Related Posts

None found

  • DashTech
  • TechDaddy
  • Terms and Conditions
  • Disclaimer
  • Write for us

© Techolac © Copyright 2019 - 2022, All Rights Reserved.

No Result
View All Result
  • Home
  • Internet
  • Business
  • Computers
  • Gadgets
  • Lifestyle
  • Phones
  • Travel
  • Tech
  • More
    • Automotive
    • Education
    • Entertainment
    • Health
    • SEO
    • Linux
    • WordPress
    • Home Improvement
    • How to
    • Games

© Techolac © Copyright 2019 - 2022, All Rights Reserved.