Assuming that by “hidden file” you mean files whose name begins with a dot or that are located somewhere under a directory whose name begins with a dot, and not other forms of invisible files, the following command prints the names of all hidden files. It's slow as it goes over all the file names everywhere on your system.
sudo find / -name '.*' \( -type d -exec find {} \; -prune -o -print \)
Explanation:
-type d -exec find {} \; -prune
executes find
on every directory (whose name matched .*
), and skips descending into that directory because of the -prune
.
-type d … -o -print
causes all non-directories that match .*
to be printed.
If you're looking for a file with a specific name or pattern:
sudo find / -name 'Foo*' -path '*/.*'
The */.*
pattern on the whole path forces matches to be under a hidden directory.
You may want to add -xdev
after the /
to avoid traversing special filesystems and removable disks.
sudo
is unnecessary unless you need to search in directories that you do not have access to. Searching in hidden directories does not require elevated privileges, if that's why it's being used in your example.