> For the complete documentation index, see [llms.txt](https://d3ndr1t30x.gitbook.io/breaking-things-a-junior-pentesters-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://d3ndr1t30x.gitbook.io/breaking-things-a-junior-pentesters-guide/finding-files-in-windows.md).

# Finding files in Windows

**Basic File Search Commands:**

1. **`dir`**: List files and directories in a directory.
   * `dir [path]`: List files and directories in the specified path.
   * Example: `dir C:\Users`
2. **`cd`**: Change directory.
   * `cd [path]`: Change the current directory to the specified path.
   * Example: `cd C:\Program Files`

**Searching for Files:**

3. **`dir /s`**: Search for files and directories recursively.
   * `dir /s [filename]`: Search for a file by name recursively.
   * Example: `dir /s myfile.txt`
4. **`where`**: Find the location of a program or file in system directories.
   * `where [executable]`: Find the location of an executable or script.
   * Example: `where notepad.exe`

**Filtering and Redirection:**

5. **`findstr`**: Search for text within files.
   * `findstr /s /i "text" [path\file_pattern]`: Search for text in files.
   * Example: `findstr /s /i "keyword" C:\folder\*.txt`
6. **`> and >>`**: Redirect output to a file.
   * `command > output.txt`: Redirect standard output to a file.
   * `command >> output.txt`: Append standard output to a file.
   * Example: `dir > directory_listing.txt`

**Advanced Searching:**

7. **`where /r`**: Recursive search for executables.
   * `where /r [directory] [filename]`: Search for executables in a directory and its subdirectories.
   * Example: `where /r C:\ProgramData\ myscript.exe`
8. **`powershell`**: Use PowerShell for advanced searches.
   * `Get-ChildItem -Path [path] -Recurse -Filter [filename]`: Recursive search using PowerShell.
   * Example: `Get-ChildItem -Path C:\ -Recurse -Filter myfile.txt`
9. **`Everything`**: Use the "Everything" search tool for lightning-fast file searches (third-party tool).

**Additional Tips:**

* Use quotation marks (`"`) around file or folder names with spaces (e.g., `"file name.txt"`).
* You can use wildcard characters (`*` and `?`) for more flexible searches (e.g., `myfile*.txt`).
* Run command prompt or PowerShell as an administrator for access to all files and directories.

Remember to replace `[path]`, `[filename]`, `[executable]`, `[directory]`, and `[text]` with the appropriate values for your specific use case.
