• Categories
    Category
  • Categories
    Category
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial Comments FAQ Related Articles

How to search Top Files and Directories in Linux

377

Top Files and Directories in Linux

Top files and directory can be found using the combination of du command which estimates file space usage, sort command to Sort lines of text files or given input data, head command to display the largest file and search file using find command.

Options

du : Estimate file space usage.
a : Displays all files and folders.
sort : Sort lines of text files.
-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.
-h : Print sizes in human readable format
-s : Display only a total for each argument.
-S : Do not include size of sub directories.

To find top directories current working directories

The following command helps to find top directories in current working directories

Example

[root@linuxhelp Desktop]# du -a | sort -n -r | head -n 3 
555440 .
449620 ./CentOS 64
448580 ./CentOS 64/CentOS 64.vmdk

To find largest files in home directory

The following command helps to find largest files in home directory

Example

[root@linuxhelp Desktop]# du -a /home/ | sort -n -r | head -n 5 
21916 /home/
21820 /home/user1
14316 /home/user1/.mozilla
14300 /home/user1/.mozilla/firefox
14292 /home/user1/.mozilla/firefox/ow95swzb.default

For more info about du command: https://www.linuxhelp.com/disk-management-linux-du-command/

To display the file size

To display the file size in human readable format, that is in KB, MB, GB

Example

[root@linuxhelp Desktop]# du -hs * | sort -rh | head -n 4 
440M CentOS 64
104M Videos
8.0K NEWPASSWD
4.0K NEW~

For more info about head and tail command: https://www.linuxhelp.com/head-tail-command/

To list the large files & directories

To list the large files, directories including sub directories in the current working directories.

Example

[root@linuxhelp Desktop]# du -Sh | sort -rh | head -n 5 
440M ./CentOS 64
39M ./Videos/cat cmd
29M ./Videos/grep command final
27M ./Videos/chmod new
8.6M ./Videos/chmod

To find only the largest file size

The following command helps to find only the largest file size and not directories in current working directory.

Example

[root@linuxhelp ~]# find -type f -exec du -Sh {} + | sort -rh | head -n 5 
439M ./Desktop/CentOS 64/CentOS 64.vmdk
86M ./.mozilla/firefox/kn1e65t9.default/urlclassifier3.sqlite
39M ./Desktop/Videos/cat cmd/cat cmd.mp4
29M ./Desktop/Videos/grep command final/grep command final.mp4
27M ./Desktop/Videos/chmod new/chmod new.mp4

To find only the biggest file size in specific location

The following command helps to find biggest file size in specific location.

Example

[root@linuxhelp ~]# find /root/ -type f -exec du -Sh {} + | sort -rh | head -n 5
439M /root/Desktop/CentOS 64/CentOS 64.vmdk
86M /root/.mozilla/firefox/kn1e65t9.default/urlclassifier3.sqlite
39M /root/Desktop/Videos/cat cmd/cat cmd.mp4
29M /root/Desktop/Videos/grep command final/grep command final.mp4
27M /root/Desktop/Videos/chmod new/chmod new.mp4

For more info about sort command: https://www.linuxhelp.com/sort-command-linux-examples/

Tags:
grayson
Author: 

Comments ( 0 )

No comments available

Add a comment

Frequently asked questions ( 5 )

Q

How to sort a file which has a size of 1GB using find command ?

A

You can use the following command to getting sort a file will be a size of 1GB using the find command. Syntax: "find / -name '*' -size +1G"

Q

How to list largest files in a directory & its subdirectories in Linux?

A

You can use the following command to list the largest files in a directory and it has a subdirectory "find /somedir -type f -print | xargs ls -l | sort -k5,5rn | head"

Q

How to list files by size in a specified order in an directory and its sub directories?

A

You can use the Following command to list files by size in a specified order in an directory and its sub directories. For ex: "ls -lR | sort -bn +4 (smallest to largest) (or) ls -lR | sor

Q

How to Sorting the output for the ‘ps’ command?

A

The ps command output is unsorted as by default. The -sort parameter forces ps to sort the output. The ascending or descending order can be specified by adding the + (ascending) or - (descend

Q

How to view the entire information ‘ps’ command output?

A

You can use the following command to view the entire information of the "ps" command. Syntax: "ps -A"

Related Tutorials in How to search Top Files and Directories in Linux

Related Tutorials in How to search Top Files and Directories in Linux

How to mount/unmount Local and Network Filesystems in Linux
How to mount/unmount Local and Network Filesystems in Linux
Jun 28, 2016
How to Create and Convert Linux File Systems
How to Create and Convert Linux File Systems
Jun 11, 2016
How to navigate to Linux filesystem using Autojump
How to navigate to Linux filesystem using Autojump
Jun 9, 2016
How to search Top Files and Directories in Linux
How to search Top Files and Directories in Linux
Mar 5, 2016
How to create File System Backup using Bash Script on Debian 12
How to create File System Backup using Bash Script on Debian 12
Jul 18, 2024

Related Forums in How to search Top Files and Directories in Linux

Related Forums in How to search Top Files and Directories in Linux

File system
kishore class=
display the mounted file system types
Oct 16, 2017
inode
caden class=
What is File System and File Format?WHat is the difference between these two?
Aug 20, 2019
File system
christian class=
How to change the partition type after creation
Apr 1, 2017
File system
david class=
How to use autojump tool to linux file system
Apr 1, 2017
File system
jacob class=
File system error (-2018375670) on Windows 10
Mar 27, 2021
Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help legeek ?
Installation of the call center module

hello

I wish to install a call center in virtual with issabel, I downloaded the latest version of it , but I don' t arrive to install the call center module in issabel. please help me

thanks!

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.