≡ Menu

Linux / Unix: Find And List All Hidden Files Recursively

I am a new Unix system shell user. I need to find and list all hidden files including directories on a Linux or Unix-like system. How can I recursively list all hidden files and directories? How do I save result in a text file?

You need to use the find command to list all hidden files recursively on a Linux or Unix like systems.

Syntax: Recursively list all hidden files and directories on Linux/Unix

The basic syntax is as follows:

find /dir/to/search/ -name ".*" -print

OR

find /dir/to/search/ -name ".*" -ls

OR search only hidden files:

find /dir/to/search/ -type f -iname ".*" -ls

OR search only hidden directories:

find /dir/to/search/ -type d -iname ".*" -ls

OR

find /dir/to/search -path '*/.*' -print
find /dir/to/search -path '*/.*' -ls

In this example, search $HOME for all hidden files and dirs:

find $HOME -name ".*" -ls

Sample outputs:

6553607    4 -rw-r--r--   1 admi     admi          100 Sep 22  2004 ./.cshrc
6553664    4 -rw-------   1 admi     admi         1024 Nov 17 04:40 ./.rnd
6553604    4 -rw-r--r--   1 admi     admi           18 May 20  2009 ./.bash_logout
6553665    4 drwx------   2 admi     admi         4096 Dec 18  2012 ./.gnupg
6553671    0 -rw-------   1 admi     admi            0 Dec 18  2012 ./.gnupg/secring.gpg
6553669    0 -rw-------   1 admi     admi            0 Dec 18  2012 ./.gnupg/pubring.gpg~
6553673    4 -rw-------   1 admi     admi          899 Dec 18  2012 ./.gnupg/pubring.gpg
6553667    8 -rw-------   1 admi     admi         7856 Dec 18  2012 ./.gnupg/gpg.conf
6553668    4 -rw-------   1 admi     admi         1200 Dec 18  2012 ./.gnupg/trustdb.gpg
6553602   20 -rw-------   1 admi     admi        17462 Apr  7 10:55 ./.bash_history
6553610    4 drwx------   3 admi     admi         4096 Jan 16  2013 ./.config
6553660    4 drwx------   2 admi     admi         4096 Jan 16  2013 ./.config/htop
6553681    4 -rw-r--r--   1 admi     admi          597 Apr 11  2013 ./.config/htop/htoprc
6553723   12 -rw-------   1 admi     admi         9629 Mar 30 23:56 ./.viminfo
6553615    4 drwxr-xr-x   3 admi     admi         4096 Nov 29  2012 ./.original-configs

To save the results to a file called foo.txt, use a redirection as follows:

find $HOME/projects/ -name ".*" -ls > foo.txt
cat foo.txt

See find(1) command man page for more information.

Share this tutorial on:

Your support makes a big difference:
I have a small favor to ask. More people are reading the nixCraft. Many of you block advertising which is your right, and advertising revenues are not sufficient to cover my operating costs. So you can see why I need to ask for your help. The nixCraft, takes a lot of my time and hard work to produce. If you use nixCraft, who likes it, helps me with donations:
Become a Supporter →    Make a contribution via Paypal/Bitcoin →   

Don't Miss Any Linux and Unix Tips

Get nixCraft in your inbox. It's free:



{ 5 comments… add one }
  • Vinoth April 8, 2014, 5:15 am

    Please try below with ls command.

    ls -lRa > List.txt

  • Chris F.A. Johnson April 8, 2014, 8:05 pm

    There is no point to using -iname since there are no alpha characters to match, and since it is non-standard, it will only work with GNU find.

  • daniel andrade April 10, 2014, 2:51 pm
    find . -name ._\* -print0 | xargs -0 rm -f

    to remove all hidden files recursively! :D

  • beware June 16, 2015, 3:11 pm

    @daniel andrade

    Why would you ever remove all hidden files recursively?

  • rrrrrrrrrrrrrr November 9, 2016, 8:48 pm

    directions unclear, my computer gave me a message to press alt + f4

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">


   Tagged with: , ,