iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Use find to select directory entries by name or metadata, du to measure space used by a directory tree, and grep to search text inside files. A dependable investigation usually runs them in that order: identify the relevant paths, measure which subdirectories or files consume space, then inspect matching content. The commands below follow GNU Findutils, GNU Coreutils, and GNU Grep behavior; other implementations can differ, so check man find, man du, and man grep on the machine you are using.
The three commands answer different questions
These utilities are complementary, not interchangeable. Choosing the command that matches the object you want to examine prevents misleading results.
| Command | Examines | Main selection language | Typical output | Important recursion or link behavior |
|---|---|---|---|---|
find |
Directory entries while walking one or more trees | Predicates and expressions for names, types, sizes, times, and other metadata | Paths, or an action performed on each match | Walks the starting tree; traversal and actions depend on its options and filesystem permissions |
du |
Filesystem space represented by files beneath named paths | Reporting and depth options | Per-path totals and summaries | Measures named trees, not free space on the mounted filesystem |
grep |
File contents | Basic regular expressions by default; extended expressions with -E; literal strings with -F |
Matching lines, normally with their text | -r recursively searches directories while skipping symlinks encountered inside; -R follows all symlinks |
If the question is “How much capacity remains on this filesystem?”, use df, not du. du can explain where a named directory tree consumes space, while df reports filesystem-level used and available capacity.
Free tools Windows power users keep installed
One-click scans. No signup required.
Check the implementation before relying on an option
Linux distributions may package different releases or non-GNU implementations. The GNU manuals associated with the documented behavior here show Findutils 4.10.0.77-733bb, Coreutils 9.11, and Grep 3.12. Your installed version can expose a different option set or default. Run these commands when troubleshooting:
#1 Best Overall
- Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
- With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
- Wide Application:Upgraded attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
- Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
- Warranty & Support: Our Electric air duster comes with 5 years warranty and 24/7 customer service. During this period, if you have any questions,pls kindly feel free to contact us.
find --version
du --version
grep --version
man find
man du
man grep
Use a directory you are allowed to read while learning. Permission errors can make an apparently empty result incomplete rather than conclusive.
Find files by name, type, and metadata
Search a known tree by filename
Give find a starting path, a test, and optionally an action. This lists regular files below ~/Documents whose names end in .pdf, regardless of letter case:
find ~/Documents -type f -iname '*.pdf'
-type f restricts matches to regular files. To list directories instead, use -type d. The quoted pattern is essential: the shell must pass *.pdf unchanged so that find, rather than the shell, applies its filename matching rule. With -name, matching is case-sensitive; -iname ignores case.
If you omit the starting path, GNU find searches the current directory (.). If you omit the expression, it prints encountered names. Being explicit about both parts makes a command easier to audit and safer to reuse.
Build an expression for precise selection
GNU find evaluates its expression separately for each entry. Combine tests to narrow a result: start with the tree, identify the entry type, then add a name, size, timestamp, or another metadata predicate. For example, this limits the search to regular configuration files:
find ~/projects -type f -name '*.conf'
Use a metadata test when content is not the issue. A filename match is cheap and predictable; a later content search should only run on the files that survive these tests.
This separation also makes troubleshooting easier. First run the metadata-only command and inspect its paths. Once the candidate set looks right, attach an action such as a grouped -exec invocation. If the final output is surprising, you can tell whether the problem is tree traversal, the filename predicate, or the content pattern instead of debugging all layers at once.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPrint results or pass them to an action
The default output is one path per line. That format is convenient for viewing, but it is not safe as an interchange format when names can contain newlines. For automation, request NUL delimiters with -print0; the next command must explicitly understand NUL-separated input.
find /var/log -type f -name '*.log' -print0
Do not assume an empty display proves there are no matches. A traversal that cannot enter a directory or inspect an entry can emit diagnostics and return a nonzero status.
Rank #2
- Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
- Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
- Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
- Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
- Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth
Use du to see where disk space goes
Get one total for a directory
For a compact total of a tree, use:
du -sh ~/Documents
-s requests a summary rather than a line for every descendant, and -h formats values with readable binary-unit suffixes. With no path operand, du measures the current directory.
Break the total down by immediate children
To identify which first-level directories deserve investigation, run:
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →du -h --max-depth=1 ~/Documents
The output includes the root and its immediate children. --max-depth=0 is equivalent to a summary of the named path. This view is often more useful than a huge recursive listing because it gives you a decision point: descend only into the largest child, then repeat the same command there.
Depth is a reporting limit, not a claim that deeper files do not exist. A child total still includes the files below that child; the command simply does not print every intermediate directory. If you need a narrower view, change the starting path to the child you are investigating rather than trying to interpret a long all-level listing.
Understand the units and what is being measured
GNU du normally reports the filesystem space required to represent files, using 1024-byte units. The human-readable form uses binary-unit suffixes. --si instead uses powers of 1000, so state which convention you used when recording or comparing values.
A filesystem-space estimate is not always the same as a file’s logical length. Add --apparent-size when you need the byte count visible through tools such as wc -c or stat:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
du -h --apparent-size -s ~/Documents
Sparse files demonstrate the difference: they can expose a large apparent size while occupying little physical space. Use ordinary du to answer “how much storage is consumed?” and --apparent-size to answer “how large are the logical files?”
When comparing two reports, keep the question and unit convention fixed. A physical-space total can change because allocation differs, while an apparent-size total reflects logical byte counts. Neither number is the free capacity of the whole mount; use df for that separate question.
Account for hard links before adding totals
GNU du counts a file with multiple hard links only once. If you pass several paths, the order of those inputs can determine which path receives that count. Consequently, adding separate du outputs can overstate usage when the trees share hard-linked files. Treat overlapping trees as one accounting set or investigate the links before summing.
Rank #3
- 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
- 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
- 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
- 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
- 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.
Search file contents with grep
Match a literal string in one file
Use -F when punctuation should be treated literally, and -n to show line numbers:
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsgrep -n -F 'server_name' /etc/nginx/nginx.conf
Without -F, characters such as ., *, and [ can have regular-expression meaning. The default pattern language is basic regular expressions. Select extended regular expressions with -E when constructs such as alternation or + make the expression clearer.
Think of the pattern mode as part of the command’s specification. A literal search is usually the least surprising choice for a setting name, error code, or quoted phrase. Choose a regular-expression mode only when you need pattern matching, and quote the expression so the shell does not reinterpret characters intended for grep.
Search a directory recursively
This example looks through project files for a regular expression and prints line numbers:
grep -r -n 'timeout.*retry' ~/projects
-r recursively searches directory operands. It follows a symlink supplied directly on the command line, but skips symlinks encountered inside the recursive walk. Use -R when you intentionally want to follow all symlinks; doing so can expand the search outside the tree you thought you were examining.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Recursive grep is a content operation, not a replacement for metadata filtering. It may inspect files you did not intend to include when a directory contains generated data, archives, or unrelated formats. When the filename type matters, select paths with find first and then invoke grep on that controlled set.
Read grep’s exit status correctly
GNU grep returns status 0 when it selects at least one line, 1 when no lines are selected, and 2 when an error occurs. A command that prints nothing may therefore mean “no match,” “a permission or input error,” or that diagnostics were overlooked. Check the status in scripts and review error messages. find likewise returns nonzero when errors occur while processing entries.
This distinction matters in automated checks. A status of 1 is a valid negative result, whereas status 2 indicates that the check was not completed reliably. Preserve stderr while testing and avoid converting every nonzero status into “nothing found.”
Combine find and grep without searching the wrong files
Use find for metadata selection and grep for content selection. This command searches regular files whose names end in .conf, prints matching lines, line numbers, and filenames, and lets one grep process handle batches of paths:
Rank #4
- 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
- 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
- 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
- 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
- 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.
find ~/projects -type f -name '*.conf'
-exec grep -nH -F 'listen' {} +
The *.conf pattern remains quoted because it belongs to find. -exec ... {} + substitutes matching paths and invokes the command with as many as practical per call, avoiding a separate process for every file. -H ensures filenames appear with matching lines, which matters when more than one file is searched.
This division of labor is more precise than a broad recursive grep when you know the relevant file type. Conversely, use recursive grep directly when metadata filtering is unnecessary and you want a quick content search.
Keep the stages visible when diagnosing a command. Run the find expression alone to verify the candidate paths, then add grep. This prevents a typo in a filename pattern from looking like a failed content match, and it makes permission warnings easier to attribute to the command that emitted them.
Use a safe pipeline for filenames with whitespace or newlines
Filenames may contain spaces, tabs, and newline characters. A newline-delimited list can split one filename into several apparent arguments, causing incorrect measurements or unintended actions. Emit NUL-delimited names from find and consume them with a NUL-aware option:
Recommended Free Tools
find /var/log -type f -name '*.log' -print0 |
du -h --files0-from=-
Here --files0-from=- tells GNU du to read NUL-terminated paths from standard input. Keep the delimiter choice consistent across every stage of a pipeline; inserting a conventional line-oriented utility in the middle can reintroduce the original problem.
NUL safety is most important when a command’s output becomes another command’s arguments. For an interactive listing, ordinary output may be readable enough, but scripts and scheduled jobs should assume arbitrary valid filenames. Test the complete pipeline with names containing spaces and newlines if the result will drive an action or a report.
Practical investigation workflows
Locate a document and verify its contents
- Start at the narrowest likely directory rather than the entire root filesystem.
- List candidate regular files with a quoted case-insensitive pattern, for example
find ~/Documents -type f -iname '*.pdf'. - If the files are text-based and you need a phrase, pass a deliberately selected set to
grep; use-Ffor a literal phrase and-nfor line numbers. - Review permissions and command status if the result is unexpectedly empty.
Find which project area is consuming storage
- Measure the project root with
du -shto establish one total. - Run
du -h --max-depth=1at that root to see immediate child totals. - Repeat the depth-one view inside the largest child until the responsible directory is clear.
- Use
findto list the file types or metadata associated with that directory, then inspect selected text withgrepif needed. - Use ordinary
dufor physical space questions and--apparent-sizewhen logical file length is the question.
Audit configuration files for a setting
- Restrict the tree and type with
find, quoting the filename pattern. - Use
-exec grep -nH -F ... {} +for a literal setting name, or omit-Fand choose the appropriate regular-expression mode for a pattern. - Read any permission diagnostics and distinguish grep status 1 (no selected lines) from status 2 (an error).
- If configuration directories contain symlinks, decide explicitly whether the search should use
grep -rorgrep -R, because their traversal differs.
Choose the narrowest tool that answers the question
A useful decision sequence keeps each command’s scope small. If you need names or metadata, begin with find and a starting path. If you need a storage total for those paths, use du; if you need remaining capacity on the mount, switch to df. If you need text inside the selected files, use grep. This avoids asking grep to discover files, asking du to report free space, or mistaking a filename match for a content match.
The sequence can be iterative rather than linear. A depth-one du report may identify a cache directory; a subsequent find run can classify its entries. A content match may reveal a configuration path that you then measure with du. Keep the object and unit of each result explicit as you move between steps.
Common mistakes and how to correct them
- Unquoted find globs:
find ~/Documents -name *.pdflets the shell expand the wildcard first. Write-name '*.pdf'so find receives the intended pattern. - Confusing globs with regular expressions: in a find name pattern,
*is a shell-style wildcard. In grep,.*is regular-expression syntax. Quote both, but use the syntax belonging to the tool interpreting it. - Using grep to answer a disk-usage question: grep can locate text, not rank directories by consumed storage. Measure with du first.
- Treating du as free-space reporting: du totals named trees. Use df for used and available space on a mounted filesystem.
- Comparing apparent and physical sizes as if they were identical: sparse files can make the logical byte count much larger than filesystem space used. Select
--apparent-sizedeliberately. - Following links unintentionally: grep
-Rfollows all symlinks, while-rskips symlinks found during recursion. Choose the behavior that matches the boundary of your audit. - Parsing ordinary find output in scripts: newline-delimited names are unsafe for arbitrary filenames. Use
-print0and a NUL-aware consumer such asdu --files0-from=-. - Ignoring diagnostics: permission failures can hide entries. Check stderr and exit statuses before concluding that no files or matches exist.
- Adding overlapping du results: hard-linked files are counted once, and input order can assign that count to one path. Do not blindly sum separate reports from trees that may share links.
Quick command reference
| Need | Command | What to notice |
|---|---|---|
| Case-insensitive PDF names | find ~/Documents -type f -iname '*.pdf' |
Quote the find pattern; restrict to regular files |
| One directory total | du -sh ~/Documents |
Summary in readable binary units |
| Immediate child totals | du -h --max-depth=1 ~/Documents |
Shows the root and its first-level children |
| Logical rather than allocated size | du -h --apparent-size -s ~/Documents |
Useful for sparse-file analysis |
| Literal text in one file | grep -n -F 'server_name' /etc/nginx/nginx.conf |
Literal matching plus line numbers |
| Recursive regular-expression search | grep -r -n 'timeout.*retry' ~/projects |
-r does not follow every symlink |
| Search selected config files | find ~/projects -type f -name '*.conf' -exec grep -nH -F 'listen' {} + |
Metadata filtering happens before content matching |
| Safe filename handoff | find /var/log -type f -name '*.log' -print0 | du -h --files0-from=- |
NUL delimiters preserve whitespace and newlines |
A reliable mental model
Think of the workflow as three layers. find answers “which entries qualify?” using directory location and metadata. du answers “how much filesystem space do these paths represent?” while keeping physical and apparent size distinct. grep answers “which lines inside the selected files match this pattern?” Once those boundaries are clear, quote the pattern for the tool that owns it, choose symlink behavior intentionally, preserve filenames with NUL delimiters in pipelines, and treat permissions and exit statuses as part of the result rather than incidental noise.
Best Value
- 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
- 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
- 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
- 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
- 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.
Frequently Asked Questions
How do I find a file by name in Linux?
Give find a starting directory, a type test, and a quoted name pattern. For example, find ~/Documents -type f -iname '*.pdf' searches regular files below ~/Documents and ignores case. Use -name instead when matching should be case-sensitive. Quoting prevents the shell from expanding the wildcard before find sees it.
How do I see which folders are taking up space?
Run du -h --max-depth=1 DIRECTORY. It reports the named directory and each immediate child in readable binary units. Descend into the largest child and repeat. Use du -sh DIRECTORY when you need only one summary total, and remember that du measures a named tree rather than free capacity on the filesystem.
What is the difference between du and file size?
Ordinary du estimates filesystem space required to represent files. du --apparent-size reports logical byte counts, similar to what tools such as wc -c or stat expose. Sparse files can have a large apparent size but consume little physical space. Hard-linked files are counted only once by GNU du.
How do I search inside files recursively with grep?
Use grep -r -n 'pattern' DIRECTORY for a recursive content search with line numbers. The default pattern language is basic regular expressions; use -E for extended expressions or -F for literal text. GNU -r skips symlinks encountered during recursion, while -R follows all symlinks.
Why does grep print nothing even though files exist?
No output can mean no line matched, a permission or input error occurred, or a traversal boundary excluded the files. Check diagnostics and grep’s status: 0 means at least one selected line, 1 means no selected lines, and 2 means an error. Also verify whether you used -r or -R and whether the pattern is literal or a regular expression.
How can I search only selected file types with grep?
Use find for metadata filtering and a grouped action for grep: find ~/projects -type f -name '*.conf' -exec grep -nH -F 'listen' {} +. The quoted pattern belongs to find, -F makes the text literal, and {} + lets each invocation process a batch of paths.
Are pipelines based on find output safe for unusual filenames?
Not if they rely on ordinary newline-delimited output. A filename may contain spaces, tabs, or newlines. Emit NUL-delimited names with find ... -print0 and use a consumer that accepts NUL input, such as GNU du --files0-from=-. Keep every pipeline stage NUL-aware.
Free tools Windows power users keep installed
One-click scans. No signup required.
Do I need to install anything or pay to use these commands?
No purchase is required for the standard Linux utilities. They are commonly provided by GNU Findutils, GNU Coreutils, and GNU Grep, although versions and implementations vary by distribution. Check --version and the local manuals when an option behaves differently.
The Bottom Line
Use find to define the paths, du to explain their storage footprint, and grep to inspect their contents. Quote patterns, distinguish globs from regular expressions, choose symlink behavior deliberately, preserve arbitrary filenames with NUL delimiters, and check permissions plus exit statuses before treating an empty result as definitive.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

