Quick_Tip_Linux

Quick Tip: Linux File Management

Read Time:32 Sec

Quick_Tip_Linux

Below are a few quick commands for managing file in Linux:

  • Display a count of the number of files in a directory
    ls -f /dir1/subdir1/subdir2 | wc -l
  • Delete all files in a directory older than 30 days
    find /dir1/subdir1/subdir2 -name "*.*" -type f -mtime +30 -exec rm -f {}
  • Find the largest 5 directories on the system
    du -hs * | sort -rh | head -5
  • Find the 5 largest files on the system
    find -type f -exec du -Sh {} + | sort -rh | head -n 5
  • Find the 5 largest files in a directory
    find /home/tecmint/Downloads/ -type f -exec du -Sh {} + | sort -rh | head -n 5

Author

Stewart Schatz

Career: Principal CNC Consultant for Syntax Systems Limited specializing Oracle JD Edwards EnterpriseOne and the technology that supports it. Side Hustle: Owner/Operator of E1Tips.com Location: Lancaster, PA USA  What I like to do: Invest in Family, Explore Technology, Lead Teams, Share Knowledge/Experience, Hunt, Hike, etc.

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

Leave a 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.

E1Tips Qucik Tip Previous post Random Windows Tip: My PC Wakes Up In The Middle Of The Night And I Don’t Know Why
needle-in-haystack Next post Needle: REST API for Server Manager