How to See Hidden Files on Linux, Mac and Unix

Files and directory names starting with a dot are treated as hidden files on operating systems derived from Unix. That means you won’t normally see these dot files in Mac OS X, Linux, FreeBSD or enterprise Unix.

Linux includes Ubuntu, Red Hat, CentOS, SuSE, Debian, Fedora & Mandriva. Unix includes Enterprise Unix like AIX, HP/UX and Solaris.

Hidden files are typically used for configuration or program history. For example:

  • .bash_history contains a Unix user’s shell configuration.
    (A Unix shell is used to enter text commands.)
  • .ssh is a directory holding configuration files for SSH.
  • .bash_history keeps the history of shell commands entered.
  • .htaccess is used to override a folder’s Apache configuration.

Files are typically hidden so they don’t distract from the files people usually work with, such as documents, movies or music.

To list hidden files in a terminal session, add the -a option to the ls (list files) command. Here you can see the difference from a normal ls:

Tazs-MacBook-Air:~ taz$ cd /Users/taz
Tazs-MacBook-Air:~ taz$ ls
Backups		Movies
Desktop		Music
Documents	Pictures
Downloads	Public
Library		Sites
Tazs-MacBook-Air:~ taz$ ls -a

The cd command means change directory to.

There are two special files in this listing. The single dot file “.” is the current directory. The double dot file “..” is the parent directory. To see how this works:

Tazs-MacBook-Air:~ taz$ pwd
Tazs-MacBook-Air:~ taz$ cd ..
Tazs-MacBook-Air:Users taz$ pwd

The pwd command means print working directory.

I’ve tested the commands above for working with hidden files on Mac OS X 10.7 Lion, Mac OS X 10.6 Snow Leopard (10.6.7, 10.6.8), Ubuntu Server 7.04, Ubuntu Server 10.10 LTS, Ubuntu Desktop 10.04, CentOS 5.1, 5.3 & 5.4, Red Hat Enterprise Linux 5.6, as well as ancient HP/UX, AIX and Solaris versions. They should work on nearly every Unix-based system.

Hackers sometimes hide files using dot files.

Nearly all file transfer programs provide an option to show hidden files. Dot files like .htaccess are essential for some websites to work. Dot files can be a security risk. Many file transfer programs show files starting with a dot by default.

If you have more questions about hidden files, please post a comment below.

Tagged , , , . Bookmark the permalink.

2 Responses to How to See Hidden Files on Linux, Mac and Unix

  1. Derek Browne says:

    Hi there. My friend allowed my hidden files to be shown – now I dont know how to re-hide them. I’m running an imac, OS X 10.6.8. Any info would be much appreciated! Thanks

  2. jim says:


    pls ignore my last post.

    i have .. learned the hard way, directory name & filename cannot be the same.


Leave a Reply

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