How to: Find/Show/List hidden directories/folders from Linux/Unix/Debian/Ubuntu/Kali Linux/RHEL/CentOS etc.

Last Updated on

1 For System with Graphical User Interface (GUI) (Usually means we boot into an interface where we can see and use cursor)

1.1 Open the “Files” program (Like File Explorer in Windows)

1.2 For most of Linux distros use Ctrl + H key combination to show all hidden files and folders/directories (Use Ctrl + H again to hide them)

CentOS - File, showing hidden files and folders, directories
CentOS – File, showing hidden files and folders, directories

(In Linux folders and Files begin with the dot “.” hence the dotfile/dot file are hidden)

2 For Terminal

List all files and folders/directories (Including non-hidden and hidden)

ls -ahlp
Terminal - Showing all files and folders, directories (including non-hidden and hidden)
Terminal – Showing all files and folders, directories (including non-hidden and hidden)

-a: do not ignore entries starting with the dot “.”
-h: with -l and -s, print sizes like 1K 234M 2G etc.
-l: use a long listing format
-p: append / indicator to directories

List only hidden files

ls -ap | grep -v / | grep "^."
ls -ap | grep -v / | egrep "^."

-v: select non-matching lines
-v /: Inverse match everything with a slash “/”, so that only files are shwon

^. : Anything start with the dot “.”

Terminal - Show all hidden files
Terminal – Show all hidden files

List only hidden folders/directories

ls -ap | grep "^\..*/$"
ls -ap | egrep "^\..*/$"
Terminal - Showing all hidden folders, directories
Terminal – Showing all hidden folders, directories

List only hidden folders/directories without showing “./” and “../”

ls -Ap | grep "^\..*/$"
ls -Ap | egrep "^\..*/$"
Terminal - Showing only hidden folders, directories without anything else
Terminal – Showing only hidden folders, directories without anything else

Bonus

grep (Global Regular Expressions Print) and egrep (Extended Global Regular Expressions Print) have same function but different ways to interpret regular expression patterns.


Leave a Reply

Your email address will not be published. Required fields are marked *