techinfoBiT
  • News
  • Startups
  • Tech
    • Internet
    • Security
  • WebMaster
    • All
    • SEO
    • Server & Hosting
    • Tools
    • WordPress
    'Sorry, This File Type Is Not Permitted for Security Reasons' How To Fix This Error in WordPress Website Development-techinfoBiT

    ‘Sorry, This File Type Is Not Permitted for Security Reasons’ How To Fix This Error in WordPress

    What is DMARC Record in DNS and Why It is Important For Email Security-techinfoBiT

    What is DMARC Record in DNS and Why It is Important For Email Security?

    How To Generate SHA-256 Hash From the Command Line on Ubuntu Server - techinfoBiT-SHA-256,Ubuntu Server, Server Solution, Linux Hashing, File Integrity, Cryptographic Hash, sha256sum, Hash Generation

    How To Generate SHA-256 Hash From the Command Line on Ubuntu Server

    Cloudflare To Deprecate Auto Minify Feature On August 5, 2024 - techinfoBiT

    Cloudflare To Deprecate Auto Minify Feature On August 5, 2024

    What is Google Analytics 4 and How to Setup GA4 for Websites - techinfoBiT

    What is Google Analytics 4 and How to Setup GA4 for Websites?

    How To Use Multiple SPF Records In A Domain | Merge Multiple SPF Easily - techinfoBiT

    How To Use Multiple SPF Records In A Domain | Merge Multiple SPF Easily

  • Science Space
  • Gadgets
    • Laptop & PCs
    • Mobile Phones
    • Wearables
  • More
    • How-To Guides
    • Reviews
    • Telecom
    • Applications
    • Press Release
No Result
View All Result
Services
techinfoBiT
  • News
  • Startups
  • Tech
    • Internet
    • Security
  • WebMaster
    • All
    • SEO
    • Server & Hosting
    • Tools
    • WordPress
    'Sorry, This File Type Is Not Permitted for Security Reasons' How To Fix This Error in WordPress Website Development-techinfoBiT

    ‘Sorry, This File Type Is Not Permitted for Security Reasons’ How To Fix This Error in WordPress

    What is DMARC Record in DNS and Why It is Important For Email Security-techinfoBiT

    What is DMARC Record in DNS and Why It is Important For Email Security?

    How To Generate SHA-256 Hash From the Command Line on Ubuntu Server - techinfoBiT-SHA-256,Ubuntu Server, Server Solution, Linux Hashing, File Integrity, Cryptographic Hash, sha256sum, Hash Generation

    How To Generate SHA-256 Hash From the Command Line on Ubuntu Server

    Cloudflare To Deprecate Auto Minify Feature On August 5, 2024 - techinfoBiT

    Cloudflare To Deprecate Auto Minify Feature On August 5, 2024

    What is Google Analytics 4 and How to Setup GA4 for Websites - techinfoBiT

    What is Google Analytics 4 and How to Setup GA4 for Websites?

    How To Use Multiple SPF Records In A Domain | Merge Multiple SPF Easily - techinfoBiT

    How To Use Multiple SPF Records In A Domain | Merge Multiple SPF Easily

  • Science Space
  • Gadgets
    • Laptop & PCs
    • Mobile Phones
    • Wearables
  • More
    • How-To Guides
    • Reviews
    • Telecom
    • Applications
    • Press Release
No Result
View All Result
techinfoBiT

Ubuntu Server: How To Find Largest File In Directory Recursively

Nishant Kumar by Nishant Kumar
March 24, 2025
Reading Time: 3 mins read
Share on FacebookShare on Twitter > XShare via WhatsAppShare on LinkedIn

When managing an Ubuntu Server, disk space can quickly become an issue, especially if large files accumulate unnoticed. If you need to identify the biggest file within a directory (including subdirectories), Linux provides several powerful command-line tools to help.

In this guide, we’ll explore different methods to find the largest file in a directory recursively, making it easy for even beginners to follow along.

You might also like

Buying an Affordable & High-Performance VPS or Web Hosting-Best VPS Offer-Hostinger-techinfoBiT Blog For-Best WordPress Hosting

Buying an Affordable & High-Performance VPS or Web Hosting

March 9, 2025
HowTo Fix Bluetooth Connection Issue in Ford EcoSport SYNC Audio-techinfoBiT

HowTo Fix Bluetooth Connection Issue in Ford EcoSport SYNC Audio

February 28, 2025

Step 1: Open the Terminal Application

  • First, you need to open a terminal on your Ubuntu Server. If you are connected via SSH, simply log in to your server.

Step 2: Switch to Root User

  • For full access, switch to the root user by running:
sudo -i
  • Enter your password if prompted.

Method 1: Using the du Command with Sorting

  • A simple and effective way to find the largest files is to use the du command in combination with sort and head.
du -a /path/to/directory/ | sort -n -r | head -n 20

Explanation:

  • du -a /path/to/directory/ → Estimates file space usage for all files and directories.
  • sort -n -r → Sorts files numerically (-n) in reverse order (-r), showing the largest files first.
  • head -n 20 → Displays the top 20 largest files.

Method 2: Using the find Command

  • The find command is a powerful tool for locating files based on size, modification time, and other attributes. To find the largest file in a directory recursively, use:
find /path/to/directory -type f -exec du -h {} + | sort -rh | head -n 1

Explanation:

  • find /path/to/directory -type f → Searches for all files in the specified directory and its subdirectories.
  • -exec du -h {} + → Uses the du (disk usage) command to display the sizes of files in a human-readable format.
  • sort -rh → Sorts the files in descending order based on size (-r for reverse order, -h for human-readable sorting).
  • head -n 1 → Displays the first (largest) file.

Method 3: Using ncdu for an Interactive View

  • If you prefer a user-friendly and interactive approach, install and use ncdu:
sudo apt install ncdu -y
ncdu /path/to/directory

Explanation:

  • ncdu scans the directory and presents an interactive interface where you can navigate and identify large files easily.

Bonus: Finding and Deleting Large Files

  • If you need to find and remove large files, use:
find /path/to/directory -type f -size +500M -exec rm -i {} \;
  • This will locate all files larger than 500MB and prompt you before deletion.

Conclusion:

By using du, find, and ncdu, you can quickly locate large files that may be consuming valuable disk space on your Ubuntu Server. These methods ensure efficient disk space management and keep your server running smoothly.

For more Linux and server management support, visit our Hosting and Server Admin Service.

Disclaimer: Portions of this content were enhanced with the assistance of ChatGPT.

Tags: Ubuntu Server
ShareTweetSendShare
Previous Post

boAt Amplifies the T20 Season 2025 as the Official Audio Partner for RCB & GT

Next Post

MeitY to Host India’s First Nano Electronics Roadshow at IISc Bengaluru

Nishant Kumar

Nishant Kumar

Nishant is a passionate tech blogger and has been writing about technology since 2007. His insatiable love for gadgets has made him closely follow the advancements & innovations our society has made in terms of technology since a long while now. Nishant is a highly sought after reviewer with many manufacturers requesting his opinions about their products. He covers Mobile Phones, Gadgets, Tools and all kind of tech products to give consumers Genuine Reviews, Buying Guides and reliable news.

Related Articles

Buying an Affordable & High-Performance VPS or Web Hosting-Best VPS Offer-Hostinger-techinfoBiT Blog For-Best WordPress Hosting

Buying an Affordable & High-Performance VPS or Web Hosting

by Nishant Kumar
March 9, 2025
0

The Virtual Private Server (VPS) is now becoming a mainstream and popular hosting option for all kinds of websites and applications. The market share of Virtual Private Servers (VPS) has...

HowTo Fix Bluetooth Connection Issue in Ford EcoSport SYNC Audio-techinfoBiT

HowTo Fix Bluetooth Connection Issue in Ford EcoSport SYNC Audio

by Suyash Anand
February 28, 2025
0

The Ford EcoSport has always been a fun-to-drive vehicle, offering a feature-packed experience that many competitors struggle to match. Unfortunately, Ford has exited the Indian market, leaving many Ford owners...

How to Get Jio eSIM Online, Jio eSIM Activation Process, eSIM Registration. Jio eSIM Activation via SMS-telecom blog-techinfoBiT

How to Get Jio eSIM Online

by techinfoBiT
October 14, 2024
0

The best option among physical and eSIM is debatable since there are some pros and cons for both types of SIM options based on the individual users. The physical SIM...

How To Generate SHA-256 Hash From the Command Line on Ubuntu Server - techinfoBiT-SHA-256,Ubuntu Server, Server Solution, Linux Hashing, File Integrity, Cryptographic Hash, sha256sum, Hash Generation

How To Generate SHA-256 Hash From the Command Line on Ubuntu Server

by Nishant Kumar
October 12, 2024
0

The SHA-256 hash is a cryptographic algorithm widely used to check the integrity of the data; especially when downloading software or managing large datasets, ensuring that files remain unaltered during...

Load More
Next Post
MeitY to Host India's First Nano Electronics Roadshow at IISc Bengaluru-techinfoBiT

MeitY to Host India's First Nano Electronics Roadshow at IISc Bengaluru

Leave a Reply Cancel reply

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


This site uses Akismet to reduce spam. Learn how your comment data is processed.

techinfoBiT | Startup & Tech News, Reviews | WebMaster, How-To Guides-Tech Blog-Startup Blog India

techinfoBiT is your go-to source for the latest startup & tech news, technology reviews; WebMaster, SEO tips and how-to guides to help you stay updated and navigate the digital world know more

  • About
  • Contacts
  • Disclaimer
  • Privacy Policy

© 2012-2025 techinfoBiT | All Rights Reserved

No Result
View All Result
  • News
  • Startups
  • Tech
  • WebMaster
  • Gadgets
  • How-To Guides
  • Science Space
  • Services

© 2012-2025 techinfoBiT | All Rights Reserved