how to show or display hidden files in linux

In Linux, as you should already know, there is the concept of hidden files and hidden folders. It is not exactly hidden in the literal sense, but all that means is that the file managers and file system utilities will not display these types of files (or folders) by default.

The hidden file concept is not a security feature and it does not provide any extra protection compared to other files. However, there are a couple of reasons (or benefits) for these kind of files.

  • These files are usually a mechanism to store user preference or system files that are not modified by user regularly.
  • They are also used by different utilities to store configuration and state of the programs. As these files are not actively used by user on a normal day-to-day basis, it makes sense to hide them in most cases.
  • It also allows the file manager utilities to prevent cluttering up the user interface and provide a soft division between user files and user specific configuration files.

Any file or folder whose name start with a dot (.) is a hidden file, also known as dot file. These files will not be displayed by default when listing the contents of a folder. These files can be referenced just as any file, by using the name of the file (including the dot).

We will see how you can view these files using the most popular directory listing commands and file managers.

ls command

The ls command is probably the most used command line utility and it lists the contents of the specified directory. In order to display all files, including the hidden files in the folder, use the -a or –all option with ls.

$ ls -a

This will display all the files, including the two implied folders: . (current directory) and .. (parent folder). If you want to omit the display of these two folders, then use the -A or –almost-all option.

$ ls -A

This is quite useful, if you are using the output of the command as input to some other script. You probably do not the script to loop in the current folder (depending on the script).

If you want to display only the hidden files, then you will need to specify a regular expression with the ls command., the following will display just the hidden file and folders.

$ ls -d .[^.]*

The -d option is to ensure that the directory contents are not printed out for each directory in the list.

dir command

Another popular command used to display directory contents is dir. Almost all options for dir is the same as ls, which means everything that was shown for ls in the previous section will work for dir as well.

$ dir -a

will display all files, hidden files and the implied folders (. and ..).

$ dir -A

will display all files, folders including the hidden folders but excluding both . and ..

$ dir -d .[^.]*

will display just the hidden files and hidden folders.

KDE File Manager (dolphin)

The default file manager in KDE is Dolphin. The default setting in Dolphin is not to display hidden or dot files. There are couple of different ways you can enable the option here.

The easiest is probably the keyboard shortcut Alt+. (Alt and dot). You can easily enable the display and disable it again using the same shortcut.

The other option is using the menu option. Click on the Hamburger icon on the menu bar (for Settings/Configuration). In the drop down menu, you will see the option named Show Hidden Files. Click and select it on it to enable the display of hidden files.

hidden files settings in dolphin

You can leave that option selected, if you want to always display the hidden files. The other commonly used file manager is Konqueror, which uses embedded dolphin to display the file system, as well.

Gnome File Manager (files or nautilus)

The default file manager in Gnome on most distros is Gnome Files. It was formerly known as Nautilus. The keyboard shortcut to display hidden files in Nautilus is Ctrl+H. This shortcut can be used to toggle the display of dot files.

The other option is to change it in the configuration. Open Edit -> Preferences and navigate to the Views tab. Select the option Shown hidden and backup files. In modern or latest versions, this option is in Files -> Preferences menu.

hidden files in Gnome files

Xfce File Manager (thunar)

Xfce is a popular light weight desktop environment, and the default file manager is thunar. The keyboard shortcut is display hidden files is again Ctrl+H just as with Gnome File Manager.

You can find the option with in the menu as well, as with other file managers. Click on View in the menu bar, and select Show Hidden Files option.

hidden files in thunar

Midnight Commander

Midnight Commander is a command line based file manager which has a loyal following. The keyboard shortcut to display dot files here is Alt + . (Alt-Period).

There is also a configuration setting with in Panel Options. Open Options from the menu and then Panel Options. Select the option Show Hidden Files.

midnight commander files options

No matter which file manager you are using, there should be an option to display hidden files. Most times, it is disabled by default and as it should be. You can try first by right clicking and checking the context menu. The next place to check is either the Settings or Preferences dialog which is often in the Edit or View menu.

As the last resort, read the manual.