Linux Tutorials

Linux discover largest file in listing recursively utilizing discover/du

SEOClerks

I have 500GB SSD put in on my Linux server. My internet server is operating out of the disk area. I have to discover a greatest or largest file regarding file measurement on the disk. How do I discover largest file in a listing recursively utilizing the discover command?

To discover a massive file regarding file measurement on disk is simple activity if you know the way to make use of the discover, du and different command. The du command used to estimate file area utilization on Linux system. The output of du handed on to the type and head command utilizing shell pipes. Allow us to see learn how to discover largest file in Linux server utilizing varied instructions.

Linux discover largest file in listing recursively utilizing discover

The process to seek out largest recordsdata together with directories in Linux is as follows:

Open the terminal applicationLogin as root consumer utilizing the sudo -i commandType du -a /dir/ | kind -n -r | head -n 20du will estimate file area usagesort will kind out the output of du commandhead will solely present prime 20 largest file in /dir/

Linux discover a greatest recordsdata in /

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

Linux discover giant recordsdata shortly with bash alias

One can search out disk area hogs with geese bash shell alias

## shell alias ##
alias geese=‘du -cks * | kind -rn | head’
### run it ###
geese

How To Find Largest Top 10 Files and Directories On Linux / UNIX / BSDHow To Discover Largest Prime 10 Recordsdata and Directories On Linux / UNIX / BSD

Discovering largest file recursively on Linux bash shell utilizing discover

One can solely checklist recordsdata and skip the directories with the discover command as a substitute of utilizing the du command, kind command and NA command mixture:
$ sudo discover / -type f -printf “%stpercentpn” | kind -n | tail -1
$ discover $HOME -type f -printf ‘%s %pn’ | kind -nr | head -10
Pattern outputs:

295599646 /dwelling/vivek/backups/lnxpcs-master.zip
302654548 /dwelling/vivek/backups/books/pdfs/unit443.wmv
313499710 /dwelling/vivek/backups/books/pdfs/magzine.rar
340414464 /dwelling/vivek/.native/share/baloo/index
346359808 /dwelling/vivek/isoimages/VMware-VMvisor-Installer-6.7.Zero-8169922.x86_64.iso
352256000 /dwelling/vivek/set up63.iso
830054400 /dwelling/vivek/linux/linux-Four.18.eight.tar
1014864333 /dwelling/vivek/backups/corpapp/vsnl_9.5.2_E_21_Linux.tar.gz
1216380038 /dwelling/vivek/backups/books/full.version.tar.gz
1787822080 /dwelling/vivek/Fedora-Workstation-Stay-x86_64-281.1.iso

Nice! I discovered the biggest recordsdata on my disk. What subsequent?>

Rely on file/dir kind you’ll be able to both transfer or delete the file. For instance, you can not take away or transfer the Linux kernel or diver directories. To delete undesirable file on Linux use the rm command:
rm -i -v /path/to/file
To do away with all recordsdata and its sub-directories recursively use following command:
rm -rf /path/to/folderName
To maneuver file to a usb pen mounted at /mnt/usb/, run the mv command:
mv /path/to/giant/file/ /mnt/usb/

Conclusion

You simply discovered learn how to search, discover and checklist largest or greatest directories/recordsdata in Linux utilizing the mixture of du/discover and different instructions. For more information see this web page or man pages of du and discover instructions:
man du
man discover
man kind
man head
man tail

Posted by: Vivek Gite

The creator is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a coach for the Linux working system/Unix shell scripting. Get the newest tutorials on SysAdmin, Linux/Unix and open supply matters through RSS/XML feed or weekly e-mail publication.

Source link

Related Articles

Back to top button