How to find all hidden files recursively on Linux

[[email protected]:~]

Sometimes you need to find hidden files on certain directories inside your pc or servers, so… here are some fast tips to do it. It’s an easy process, it takes 1 minute and [[email protected]:~]’t not require root privileges. At the end you will also bea ble to save the results of the hidden files found on a txt [[email protected]:~].

Note: on all examples, replace /your/directory/ with your real path, it could be $ HOME to search all over your home directory, or another directory inside that place.
Syntax #1 using print

Command to Recursively list all the hidden files and directories on Linux

find /your/directory/ -name ".*" -print

Syntax #2 with ls

find /your/directory/-name ".*" -ls

Command to Recursively search only hidden files or directories

Search hidden files only

find /your/directory/ -type f -iname ".*" -ls

Search hidden directories only

find /your/directory/ -type d -iname ".*" -ls

Working example:

 [[email protected]:~]find /home -name ".*" -print /home/user1/.bash_logout /home/user1/.bashrc /home/user1/.bash_profile /home/user2/.config /home/user2/.bash_history /home/user2/.bash_logout /home/user2/.bashrc /home/user2/.bash_profile /home/user2/.pki /home/user2/.mysql_history /home/user3/.bash_logout /home/user3/.bashrc /home/user3/.bash_profile

Finally, save the results into a txt file

Open a new terminal/shell on your Linux box and type:

find $ HOME/ -name ".*" -ls > example.txt

To view the saved content type:

cat example.txt

If you know other ways to find hidden files recursively on Linux please share it with us.

Leave a Reply