How to ls hidden files in linux

Content on WhatAnswers is provided "as is" for informational purposes. While we strive for accuracy, we make no guarantees. Content is AI-assisted and should not be used as professional advice.

Last updated: April 4, 2026

Quick Answer: Use the 'ls -a' command to display all files including hidden ones in Linux, which begin with a dot (.) character. You can also use 'ls -la' to show hidden files with detailed information including permissions, owner, size, and modification date. For more detailed view of hidden files only, use 'ls -ld .*' to list dot-files explicitly.

Key Facts

What It Is

In Linux and Unix systems, hidden files are regular files whose names begin with a dot (.) character, making them invisible to standard 'ls' directory listings. The 'ls' command by default excludes these hidden files from output as a convention to reduce visual clutter and protect system configuration files from accidental deletion or modification. Hidden files are not actually hidden from the operating system or file permissions; they are simply excluded from basic directory listings by design. This naming convention has been part of Unix since its creation in 1971 and remains the standard across all Linux distributions today.

The history of hidden files in Unix dates back to the early 1970s when Ken Thompson and Dennis Ritchie implemented the dot-prefix convention in the first Unix operating system. The original rationale was to exclude the '.' (current directory) and '..' (parent directory) entries from cluttering directory listings, but developers extended this concept to user configuration files. By the 1980s, numerous hidden configuration files like .bashrc, .profile, and .cshrc became standard in Unix systems. The convention proved so practical that it persists across every Linux distribution and remains unchanged in modern systems like Linux kernel 6.8 released in 2024.

Hidden files encompass several important categories in Linux systems. Configuration files like .bashrc, .gitconfig, and .ssh/authorized_keys control application behavior and user settings. Hidden directories like .cache, .local, and .config store application data and preferences without cluttering the home directory. Temporary files and backup files often use dot-prefixes to remain hidden during normal browsing. Version control systems like Git create hidden .git directories to store repository metadata and history, making the version control transparent to casual directory browsing.

How It Works

The 'ls' command uses pattern matching in the file system to determine which files to display in listings. When executed without flags, 'ls' internally filters out any file whose name begins with a dot character, effectively hiding them from view. The -a flag (all files) disables this filtering mechanism and includes every file in the directory regardless of whether the name starts with a dot. The underlying system calls used by 'ls' (readdir() in C) return all directory entries, but the 'ls' program itself decides which ones to display based on the flags provided.

A practical example demonstrates this functionality: in a Linux home directory, 'ls' shows directories like Documents, Downloads, and Pictures, but 'ls -a' additionally reveals .bashrc, .ssh, .gitconfig, .cache, and .local directories. A system administrator managing user accounts might use 'ls -a /home/username' to verify that configuration files are present and properly initialized. DevOps engineers use 'ls -la ~/.ssh' to list SSH keys with their permissions (crucial for security verification), where the long format reveals owner, group, and permission bits. Web developers frequently use 'ls -a' in project directories to check for .gitignore, .env, and .eslintrc configuration files.

To implement listing of hidden files, open a Linux terminal and navigate to your desired directory using 'cd'. Type 'ls -a' to display all files including hidden ones, or 'ls -la' for a detailed listing with permissions and timestamps. For viewing only hidden files, use 'ls -ld .*' which lists dot-prefixed entries explicitly. To search for specific hidden files, combine with grep: 'ls -a | grep bash' finds all hidden files containing 'bash' in their name. Create a shell alias with 'alias ll="ls -la"' to make detailed directory listing more convenient in future sessions.

Why It Matters

Understanding hidden files is critical for effective Linux system administration and development, with studies showing that Linux users spend approximately 30-40% of their time in terminal environments managing configuration and hidden files. System administrators must frequently access hidden files in /root/.ssh for SSH key management, affecting server security and authentication workflows. Developers working with version control systems like Git need to understand that the .git directory is hidden by default, yet contains the entire repository history and configuration. Users migrating from Windows to Linux often struggle initially because hidden file conventions differ dramatically, making this knowledge essential for the transition.

Hidden files have critical applications across various professional domains and tools. Software developers use hidden files extensively: .gitignore files control which files are tracked in repositories, .env files store sensitive environment variables, and .eslintrc files configure code linting rules. System administrators manage hidden files like .ssh/authorized_keys to control remote access and /etc/shadow (system-wide hidden file) for password storage. DevOps engineers use hidden Docker configuration files in ~/.docker/config.json to store registry credentials. Database administrators use hidden configuration files like ~/.my.cnf to store MySQL connection credentials, eliminating the need to pass passwords on command lines.

The significance of hidden files continues to grow with modern development practices and containerization. Cloud-native applications increasingly rely on hidden dotfiles for configuration management, with infrastructure-as-code tools like Terraform using hidden directories to cache state and modules. The growth of DevSecOps practices has heightened awareness of hidden files containing secrets, driving development of security tools specifically designed to scan hidden directories for leaked credentials or misconfigurations. Future Linux development will likely maintain the hidden file convention indefinitely as it represents a fundamental design principle that has proven flexible and durable across five decades of Unix and Linux evolution.

Common Misconceptions

A widespread misconception is that hidden files in Linux provide actual security protection, when in fact they offer only visibility reduction for convenience. Hidden files have identical permissions to regular files and are not protected from access if someone explicitly names them, which is why .ssh directories contain strict 700 permissions enforced separately. Users sometimes believe that hidden files require special access to view, when in reality 'ls -a' is a normal unprivileged command that any user can execute. The 'hidden' designation is purely a naming convention respected by the 'ls' command and file managers; the operating system treats dot-prefixed files identically to other files.

Another misconception is that all configuration files in Linux must be hidden, when in fact the dot-prefix convention is simply common practice rather than a requirement. Applications can and do create configuration files with regular names; for example, many programs use .config directories containing visible configuration files inside. Some users assume hidden files are temporary or unnecessary, when in reality they contain critical system configuration that directly affects application behavior and user preferences. Backup tools and archiving applications sometimes exclude hidden files by default (using tar without -a flag), leading to incorrect backup procedures if users don't understand that .ssh, .gnupg, and other hidden directories contain essential data requiring backup.

A third misconception is that listing hidden files with 'ls -a' reveals all files on a Linux system, when it only shows hidden files in the specified directory and does not recursively descend into subdirectories to find hidden files elsewhere. Users sometimes delete hidden files thinking they are temporary or system junk, when files like .bashrc and .bash_history are essential for shell functionality and session history. Some believe that hidden files cannot be executed or run, when in reality hidden scripts and programs execute identically to visible ones; for example, ~/.local/bin/my_hidden_script can run just as any other executable. Finally, a common error is assuming that the dot-prefix hiding mechanism applies to all Unix and Linux systems identically, when some specialized systems or configurations may have different conventions or display hidden files by default.

Related Questions

How do I show hidden files in Linux file manager GUI?

In most Linux file managers like Nautilus (GNOME) and Dolphin (KDE), use Ctrl+H to toggle hidden files visibility. You can also access this through the menu: View > Show Hidden Files, or right-click in the file manager window to find the hidden files option. This GUI toggle provides the same functionality as the 'ls -a' command for graphical users.

What is the difference between 'ls -a' and 'ls -A' in Linux?

The '-a' flag shows all files including '.' and '..' special directory references, while '-A' (capital A) shows all files except these special dot entries. Use '-A' when you want to see hidden files but don't need to see the current and parent directory markers. Both flags reveal files beginning with a dot, like .bashrc and .ssh.

Can I use wildcards to find hidden files in Linux?

Yes, wildcards work with hidden files: 'ls -d .*' lists all hidden directories, while 'ls .[a-z]*' lists hidden files starting with lowercase letters. The pattern 'ls -la ~/.*' can search recursively for hidden files in your home directory. Note that wildcards must explicitly include the dot prefix to match hidden files, since the default glob patterns don't include dot-prefixed names.

Sources

  1. Wikipedia - UnixCC-BY-SA-4.0
  2. Linux man page - ls commandCC-BY-SA-2.0

Missing an answer?

Suggest a question and we'll generate an answer for it.