lazyhacker 2 years ago

find command CheatSheet

Basic Examples:

# Search for files or directories with the exact name "example.txt" in the current directory (and its subdirectories).

find . -name "example.txt"   

# Find all directories in the "/home" directory.     

find /home -type d 

# Search for files owned by the user "john" in the "/data" directory.           

find /data -user john  

# Find all files with the extension ".txt" in the current directory and download them using `curl`.          

find . -type f -name "*.txt" -exec curl -O {} \; 

Intermediate Examples:

# Extract specific content from a webpage using `curl` and `sed`.

curl https://example.com/page.html | sed -n 's/<p>\(.*\)<\/p>/\1/p'  

# Find all directories in the "/home" directory and count the number of files in each using `find` and `wc`.

find /home -type d -exec sh -c 'echo -n "{}: "; find "{}" -type f | wc -l' \; 

# Find all files modified in the last 7 days and perform an HTTP POST request with their content using `find`, `curl`, and `xargs`.

find . -type f -mtime -7 -print0 | xargs -0 -I{} curl -X POST -d @{} https://api.example.com/upload 

# Search for files with the extension ".log" in the "/var/logs" directory, compress them, and store in a backup folder using `find`, `curl`, and `tar`.

find /var/logs -type f -name "*.log" -exec tar czvf /backup/logs_backup.tar.gz {} \;  

Advanced Examples:

# Find all files in the current directory larger than 10MB and delete them using `find` and `rm`.

find . -type f -size +10M -exec rm {} \; 


0
3.5K
CPTS Preparation Guide 2025

CPTS Preparation Guide 2025

defaultuser.png
lazyhacker
3 months ago
Certificate  HTB Writeup | HacktheBox | Season 8

Certificate HTB Writeup | HacktheBox | Season 8

https://lh3.googleusercontent.com/a/ACg8ocIkM8EGIx0gz9GUP_nM6_sMxivr6876Wp0e9MAp6mGc=s96-c
xone
5 months ago
OSCP+ Preparation Guide: A Beginner-Friendly Step-by-Step Approach

OSCP+ Preparation Guide: A Beginner-Friendly Step-by-Step Approach

defaultuser.png
lazyhacker
3 months ago
What is penetration testing?

What is penetration testing?

https://lh3.googleusercontent.com/a/ACg8ocIkM8EGIx0gz9GUP_nM6_sMxivr6876Wp0e9MAp6mGc=s96-c
xone
1 year ago

The golden Era of technology

defaultuser.png
Kend
2 years ago