•  Home
  •  Dashboard
  •  Company
    • About Us
    • Blog
    • Careers
    • Contact Us
    • Data Centers
    • Looking Glass
    • Network
    • Reseller
  •  Hosting Services
    • Backup
    • Content Delivery Network
    • Colocation Hosting
    • Dedicated Hosting
    • DDoS Mitigation
    • IP Transit
    • Private Cloud
    • Wavelength
  •  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
    • Dedicated Servers
    • Colocation
    • Private Cloud
    • DDos Protection
    • IP Transit
    • CDN
    • Backup
  • Solutions
    • Ecommerce
    • Security
    • Gaming
    • Hosting
    • Management
    • Finance
    • System Integrator
  • Dashboard

Linux Command for Find Directory

Trusted By
25,000+ Customers (Since 2001)
  • 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?
  • Linux File Permissions Cheat Sheet
  • apt get command not found
  • Top Five Open Source Backup Software for Linux
  • Top Useful Features Of Linux Mint
  • Scientific Linux and its features
  • What Scientific Linux is and its features
  • Smart guide to managing Docker container
  • SCP Command Syntax Examples in Linux
  • How to setup a dedicated server for 7 days to die
  • How to setup a dedicated server for Minecraft
Hosting Services
  • Dedicated Hosting
  • Colocation Hosting
  • Backup
  • IP Transit
  • DDoS Mitigation
Support
  • Portal Login
  • Knowledgebase
  • Community
Company
  • About Us
  • Contact Us
  • Network
  • Data Centers
  • Looking Glass
  • Affiliates
  • Reseller
  • Blog
Policies
  • Privacy Policy
  • Acceptable Usage Policy
  • Terms and Conditions
  • Service Level Agreement
Company
  • Psychz Networks,
    A Profuse Solutions Company
    611 Wilshire Blvd #300
    Los Angeles,California 90017
    USA
  • US/Canada: 800-933-1517
  • International: 626-549-2801
Subscribe to Our Mailing List
* indicates required
Copyright © 2022 Psychz Networks, A Profuse Solutions Inc Company