Bash Shell: Display All Hidden Dot Files In a Directory

How do I display only hidden (dot) files names under Linux / UNIX / Apple OS X / *BSD family operating systems?

You can view only hidden files or directories in the current directory, using ls command and shell patterns.

Bash list only hidden files

Tutorial details
Difficulty Easy (rss)
Root privileges No
Requirements Bash
Time N/A
Use ls -a command to display all hidden dot files. The -a option do not hide entries starting with . in the current directory or given path. Type the following command:

$ ls -a

Sample outputs:

gimp.txt                                                .viminfo
.gnome                                                  vivek-feed.xml
.gnome2                                                 .vlc
.gnome2_private                                         .vmware
.gnome-desktop                                          .wine
.gnome_private                                          Woh Lamhe - 2006-MP3-VBR-128Kbps
go.html                                                 .Xauthority

As you see output includes all the files including hidden dot files. To just display dot files use any one of the following command:
$ ls -a | egrep '^\.'
$ ls -A | egrep '^\.'

OR
$ ls -l ~/.[^.]* | less
OR
$ ls -ld ~/.[^.]*
OR
$ ls -l ~/.??*
OR
$ ls -ld ~/.??*
Sample outputs:

You can create an alias and put into your ~/.bash_profile or ~/.bashrc file:
$ vi ~/.bash_profile
Append the following line:
alias lh='ls -a | egrep "^\."'
OR
alias lh='ls -l .??*'
alias lhd='ls -ld .??*'

Save and close the file. Now you can use lh or lhd commands to display only hidden dot files under Unix like operating systems.
$ lh
OR
$ lhd
Sample outputs:

Fig.01: HowTo: use terminal ls command to see hidden dot files

🐧 If you liked this page, please support my work on Patreon or with a donation.
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
8 comments… add one
  • James Apr 2, 2009 @ 17:17

    If you use grep you will lose formatting (multi-column) and colour.

    If you use “ls -Ad .*”, it will show you all hidden (dot) files and retain the formatting and colour. The “-d” argument is used to only show the top-level files and not contents of hidden directories.

    Thanks for the tip, I didn’t know about the -A argument.

  • Jamie Aug 26, 2012 @ 9:14

    I have some files I hid using ‘chflags hidden MyHiddenFolder’. When using ‘ls -la’ the hidden files and folders show a @ symbol next to it. After doing some research I found out that is for signifying Extended Attributes.

    When doing a ‘ls -@’ you can see that the files I changed with ‘chflags’ to hidden have a “com.apple.FinderInfo”. Do you know a way to ‘ls’ for files with Extended Attributes and more specifically just the ones that are hidden? Other files can have Extended Attributes and not be hidden.

    Basically I wanted to clean up my Finder views by hiding files and folders I don’t use often and don’t want to see. However, I want to have a way to find all files/folders I have done that to so I have a way to go over which ones I have done that to.

    • jon kwong Feb 22, 2013 @ 23:29

      Try ls .?*
      that is “dot question_mark asterisk”
      That works for me.

  • sama Jul 31, 2013 @ 23:19

    Is there a way we can see this in nautilus ( ubuntu file browser ) ? how can i see all files i.e init.d files in gui !

  • Donavon Jan 26, 2014 @ 15:21

    $ ls -a display all hidden dot files

  • Belmondo Jun 7, 2014 @ 17:50

    what does this do differently to $ls -a ?
    $ls -a .*

  • Christoffer Aasted Sep 9, 2014 @ 16:49

    ls -d .*

    Another great and short one.

  • Hastur Jan 22, 2016 @ 10:59

    **Warning** with ‘alias lh='ls -l .??*' you will not see file with only one character after the dot, as for example `.a` or `.b`…
    So instead of

    alias lh='ls -l .??*'
    alias lhd='ls -ld .??*'

    it is better
    alias lh='ls -lA | egrep " \." '
    alias lhd='ls -ldA | egrep " \." '

Leave a Reply

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

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.