•  Home
  •  Dashboard
  •  Company
    • About Us
    • Blog
    • Careers
    • Contact Us
    • Data Centers
    • Looking Glass
    • Network
    • Reseller
  •  Hosting Services
    • Infrastructure
      • iColocation
    • Compute
      • cMetal
      • cVirtual
    • Storage
      • sObject
      • sBlock
    • Networking
      • nCDN
      • nIP Transit
      • nWavelength
    • Protection
      • pBackup
      • pDDoS
  •  Solutions
    • Ecommerce
    • Finance
    • Gaming
    • Hosting
    • Management
    • Security
    • System Integrator
  •  Support
    • Community
    • Knowledge Base
    • Open A Ticket
  •  USA & Canada: 800-933-1517
  •  International: 626-549-2801
  •  Email: sales@psychz.net
  • Services
    • new-colocation-header-img
      Infrastructure
      • iColocation
    • new-compute-header-img
      Compute
      • cMetal
      • cVirtual
    • new-storage-header-img
      Storage
      • sObject
      • sBlock
    • new-networking-header-img
      Networking
      • nCDN
      • nIP Transit
      • nWavelength
    • new-protection-header-img
      Protection
      • pBackup
      • pDDoS
  • Solutions
    • Ecommerce
    • Security
    • Gaming
    • Hosting
    • Management
    • Finance
    • System Integrator
  • Dashboard

Linux Command for Find Directory

  • Home
  • Client
  • Qa Forum
  • Linux Command for Find Directory

Posted By: Robert | 1 Replies | Last Reply On: Aug 01, 2019 06:04:49

How can i find a directory in a Linux system?  Mainly trying to get list of directories and their total file size.  Sort them by large to small in disk usage. 

Psychz - Amol

Votes: 0Posted On: Aug 01, 2019 06:04:49
 

In Linux operating system, the 'find' command allows you to search for files. Even if you know the approximate filenames. The simplest form of the command searches for files in the current directory and recursively through its subdirectories that match the supplied search criteria. You can search for files by name, owner, group, type, permissions, date, and other criteria.

If you want to search for folders/directories you can use following descriptor that you can use to specify the type of file are here:

# find / -type d -name "folder_name"

In the above case we have performed search for a directory under root directory '/'

Now we will see how to find the largest folders in the Linux file system using 'du' command.

root@user1:# du -a /home | sort -n -r | head -n 10

Output 

53999   /home/user1
53999   /home
49755   /home/user1/scripts
49751   /home/user1/scripts/democontent
40111   /home/user1/scripts/democontent/rest-Api
39367   /home/user1/scripts/democontent/tools/modules
23252   /home/user1/scripts/democontent/tools/modules/npm
19753   /home/user1/scripts/democontent/tools/modules/npm/node_modules
8444    /home/user1/scripts/democontent/.git
7564    /home/user1/scripts/democontent/.git/objects/pack
root@user1:#

The Parameters used above and their usage/significance

du : Estimate file space usage.
a : Displays all files and folders.
sort : Sort lines of text files (the output in this case)
-n : Compare according to string numerical value.
-r : Reverse the result of comparisons.
head : Output the first part of files.
-n : Print the first ‘n’ lines. (In our case, We displayed first 10 lines).
| (known as pipe) : lets you use two or more commands such that output of one command serves as input to the next.


Hope you find above information helpful and informative. Kindly upvote this response if you like it.

Was this reply helpful?

Related topics

  • Basic and useful Linux commands
  • How to find a file using find and locate command on Linux?
  • Linux Find Commands
  • How To ZIp A Directory In Linux?
  • How to search in Linux?
  • apt get command not found
  • Linux File Permissions Cheat Sheet
  • Top Five Open Source Backup Software for Linux
  • Deploy Psychz Dedicated Server Using Terraform Provider
  • SCP Command Syntax Examples in Linux
  • NFT Domains - A new generation of domains
  • EasyApache 4: better than ever?
  • cVirtual Connect from Windows
  • How to setup a dedicated server for Unturned
  • In Comparison: Linux VS UNIX
Copyright © 2025 Psychz Networks,
A Profuse Solutions Inc Company
Hosting Services
Infrastructure
  • iColocation
Compute
  • cMetal
  • cVirtual
Storage
  • sObject
  • sBlock
Networking
  • nCDN
  • nIP Transit
  • nWavelength
Protection
  • pBackup
  • pDDoS
Company
  • About Us
  • Blog
  • Careers
  • Contact Us
  • Data Centers
  • Looking Glass
  • Network
  • Reseller
Policies
  • Acceptable Usage Policy
  • Privacy Policy
  • Service Level Agreement
  • Terms and Conditions
Support
  • Community
  • Knowledge Base
  • Open A Ticket
Get In Touch
  • Psychz Networks,
    A Profuse Solutions Company
    611 Wilshire Blvd #300
    Los Angeles,California 90017
    USA
  • US/Canada: 800-933-1517
  • International: 626-549-2801