Skip to main content
XsiSec.com
HomeReposBlogProjectsPortfolio
© 2026 XsiSec.com
Security rules |security.txt
Updated 2026-08-15 · v1.0.0+2026-08-14.82f92cb · 82f92cb
← Back to overview
Security article

HTB Academy - Fundamentals - Find Files and Directories

HTB Academy - Fundamentals - Find Files and Directories: 🎯 Tasks 1) Find the config file created after 2020-03-03 whose size is >25 KiB and <28 KiB. 2) Count how many files on the system have the .bak extension. • HTB Academy • htb-academy, linux-fundamentals

2022-09-152 tags
Tags

🎯 Tasks

  1. Find the config file created after 2020-03-03 whose size is >25 KiB and <28 KiB.
  2. Count how many files on the system have the *.bak extension.

✅ Recommended Commands

1) Locate the matching “.conf” file

Use GNU find with clear size units, date filtering, and a tidy printout:

bash
# Fast & tidy (stays on current filesystem only; drop -xdev if you want to traverse all mounts)
sudo find / -xdev -type f -name "*.conf"   -size +25k -size -28k   -newermt "2020-03-03"   -printf "%p	%k KiB	%TY-%Tm-%Td %TH:%TM
" 2>/dev/null | sort

Notes

  • -type f → files only.
  • -size +25k -size -28k → strictly greater than 25 KiB and strictly less than 28 KiB.
  • -newermt "2020-03-03" → modified after this date (mtime).
    • If your lab means “on 2020‑03‑04 only”, add an upper bound:
    bash
    ... -newermt "2020-03-03" ! -newermt "2020-03-04" ...
  • -printf shows: path, size (KiB), and timestamp so you can confirm quickly.
  • 2>/dev/null hides permission errors; keep it outside find options (as you did).

Answer 1 (fill from output): _______________________________


2) Count files ending with “.bak” (case‑insensitive)

bash
sudo find / -xdev -type f -iname "*.bak" 2>/dev/null | wc -l

Faster variant (avoids spawning wc on long lines):

bash
sudo find / -xdev -type f -iname "*.bak" -printf "." 2>/dev/null | wc -c

Answer 2 (number): _______


💡 Extra Tips

  • Creation vs modification time: Linux generally tracks modification (mtime), access (atime), and status change (ctime). “Created after” in labs usually means filtering by mtime (-newermt). If you truly need ctime (status changes), GNU find supports:
    bash
    -newerct "2020-03-03"
  • Traverse all mounts: remove -xdev if you need to search across /proc, /sys, /run, extra disks, etc. Expect it to be slower.
  • Skip noisy trees without -xdev:
    bash
    sudo find /     -path /proc -prune -o -path /sys -prune -o -path /run -prune -o     -type f -iname "*.bak" -print 2>/dev/null | wc -l
  • Preview with ls: if you want a long listing for each hit:
    bash
    sudo find / -type f -name "*.conf" -size +25k -size -28k -newermt "2020-03-03"     -exec ls -al {} + 2>/dev/null

🧪 Your one‑liners (from the lab)

  • Sized range sample:
    bash
    find . -type f -size +30k -size -40k -exec ls -l {} +
  • Your tailored filter (good!):
    bash
    find / -iname "*.conf" -size +25k -size -28k -newermt 2020-03-03 2>/dev/null
    Add -type f and consider -printf for clean answers as shown above.

Good luck! Once you paste the outputs, I can sanity‑check them and format the final answers for you.

Navigate

In this post

  1. 01🎯 Tasks
  2. 02✅ Recommended Commands
  3. 031) Locate the matching “.conf” file
  4. 042) Count files ending with “.bak” (case‑insensitive)
  5. 05💡 Extra Tips
  6. 06🧪 Your one‑liners (from the lab)
Search
Explore

Popular tags

Browse all 30 tags

Comments

0 comments

No comments yet — be the first to comment.