How To See Hidden Files In Linux Terminal – Applying Ls Alias For Visibility

Your Linux terminal can show hidden files with a straightforward flag added to the list command. If you’ve ever wondered how to see hidden files in linux terminal, you are in the right place. Hidden files in Linux start with a dot (.) and are often configuration files or system data. This guide will walk you through every method, from basic commands to advanced tricks.

Hidden files are not actually secret — they are just not shown by default. The terminal gives you full control to view them whenever you need. Let’s start with the simplest way.

Using The Ls Command With The -A Flag

The most common way to view hidden files is by using the ls command with the -a flag. This flag stands for “all” and shows every file, including hidden ones.

  1. Open your terminal.
  2. Type ls -a and press Enter.
  3. You will see all files, including those starting with a dot.

For example, if you run ls -a in your home directory, you might see .bashrc, .profile, or .config. These are hidden files that help configure your system.

The -a flag also shows the current directory (.) and parent directory (..). If you want to skip these, use the -A flag instead. The -A flag shows almost all files but omits . and ...

Using Ls -A For A Cleaner Output

Type ls -A to see hidden files without the extra directory entries. This is often preferred for scripting or when you want a cleaner list.

Both ls -a and ls -A

How To See Hidden Files In Linux Terminal With Long Listing

Sometimes you need more details about hidden files, like permissions, size, or modification date. Combine the -l flag with -a or -A.

Run ls -la or ls -lA. The -l flag gives a long listing format. You will see file permissions, owner, group, size, and timestamp.

Example output for ls -la:

-rw-r--r-- 1 user user 1234 Jan 15 10:00 .bashrc
drwxr-xr-x 2 user user 4096 Jan 15 10:00 .config

This is extremely useful when you need to inspect hidden configuration files. The long listing tells you if a file is readable, writable, or executable.

Sorting Hidden Files By Size Or Date

You can sort hidden files using additional flags. For example, ls -lat sorts by modification time, newest first. ls -laS sorts by file size, largest first.

These combinations are powerfull for managing hidden files in directories with many entries.

Viewing Hidden Files In Specific Directories

You don’t have to be in the directory to see its hidden files. Just provide the path.

For instance, ls -la /etc shows all files, including hidden ones, in the /etc directory. This works with any path, absolute or relative.

If you want to see hidden files in the parent directory, use ls -la ... The double dot represents the parent directory.

Using Wildcards With Hidden Files

Wildcards like * and ? work with hidden files, but you need to be careful. The * wildcard does not match hidden files by default. To match hidden files, use .*.

For example, ls -d .* lists only hidden files and directories in the current directory. The -d flag prevents listing contents of directories.

This is a handy trick when you want to see only hidden items, not regular files.

How To See Hidden Files In Linux Terminal Using Find Command

The find command is more flexible for searching hidden files across directories. Use it to locate all hidden files in a directory tree.

Basic syntax: find /path -name ".*". This finds all files and directories starting with a dot.

To find only files (not directories), use find /path -type f -name ".*". For directories only, use -type d.

Example: find ~ -type f -name ".*" lists all hidden files in your home directory.

Finding Hidden Files With Specific Extensions

You can combine patterns. For instance, find ~ -name ".*.conf" finds hidden configuration files ending in .conf. This is great for system administration.

The find command is extremly powerfull for bulk operations, like deleting or moving hidden files.

Using Grep To Filter Hidden File Lists

Sometimes you want to see only hidden files from a regular ls output. Pipe the output to grep.

Run ls -l | grep "^\.". The caret (^) matches the start of a line, and the dot (\.) matches a literal dot. This filters lines starting with a dot.

This method is usefull when you have a mix of files and want to isolate hidden ones quickly.

Combining Grep With Other Commands

You can also use ls -A | grep "^\." to list only hidden files without the . and .. entries. This gives a clean list of hidden items.

For a more advanced filter, use ls -la | grep "^-.*\." to show only hidden regular files (not directories).

How To See Hidden Files In Linux Terminal With Tree Command

The tree command displays directory structures in a tree format. To include hidden files, use the -a flag.

Run tree -a to see all files, including hidden ones, in a visual tree. This is excellent for understanding directory layouts.

You can limit depth with -L. For example, tree -a -L 2 shows two levels of directories with hidden files.

The tree command might not be installed by default. Install it with sudo apt install tree on Debian/Ubuntu or sudo dnf install tree on Fedora.

Using Tree With Color Output

Add the -C flag for colorized output: tree -a -C. Colors help distinguish files, directories, and hidden items.

This is a visual and intuitive way to explore hidden files, especially for beginners.

How To See Hidden Files In Linux Terminal Using Bash Globbing

Bash has a feature called globbing that lets you expand patterns. To list hidden files, use the pattern .*.

Type echo .* to see all hidden files and directories in the current directory. This prints them as a space-separated list.

For a more detailed view, use ls -ld .*. The -d flag prevents listing directory contents.

Globbing is usefull in scripts when you need to iterate over hidden files.

Enabling Dotglob In Bash

If you want the * wildcard to match hidden files by default, set the dotglob shell option. Run shopt -s dotglob in your terminal.

After this, ls * will show hidden files as well. To disable it, use shopt -u dotglob.

This is a permanent change only if you add it to your .bashrc file.

How To See Hidden Files In Linux Terminal With Graphical File Managers

While this guide focuses on the terminal, many graphical file managers have a keyboard shortcut to show hidden files. For example, in Nautilus (GNOME), press Ctrl+H.

But the terminal gives you more control and is faster for bulk operations. Knowing both methods is usefull.

In the terminal, you can also use mc (Midnight Commander) and press Ctrl+H to toggle hidden files.

Using Alias For Quick Access

Create an alias in your .bashrc file to save time. Add this line: alias lh='ls -lah'. Then typing lh shows all files with details.

Reload your .bashrc with source ~/.bashrc. Now you have a custom command for viewing hidden files.

This is a productivity booster for daily terminal use.

Common Mistakes When Viewing Hidden Files

One common mistake is forgetting the -a flag and wondering why files are missing. Another is using ls .* which can list contents of hidden directories.

Always use ls -d .* if you want to avoid expanding directories. Also, be careful with wildcards in scripts — they can cause unexpected behavior.

Another mistake is assuming hidden files are secure. They are not — any user can see them with the right command. Use proper permissions for sensitive data.

Hidden Files Vs. Secret Files

Hidden files are not encrypted or protected. They are simply not displayed by default. For real security, use encryption tools like gpg or openssl.

Understanding this distinction is important for system security.

How To See Hidden Files In Linux Terminal With Python Or Perl

If you prefer scripting, you can use Python to list hidden files. Here is a simple one-liner:

python3 -c "import os; print([f for f in os.listdir('.') if f.startswith('.')])"

This prints a list of hidden files in the current directory. You can modify the path as needed.

Similarly, Perl can do the job: perl -e 'opendir(D, "."); print grep /^\./, readdir(D); closedir(D)'

These methods are usefull when you need to integrate hidden file listing into larger scripts.

Using Stat To Get Details Of Hidden Files

The stat command gives detailed metadata about a file. For a hidden file, run stat .bashrc. This shows size, permissions, timestamps, and more.

Combine with find to get stats for multiple hidden files: find ~ -name ".*" -exec stat {} \;

This is advanced but very powerfull for system auditing.

How To See Hidden Files In Linux Terminal On Different Distributions

The commands work the same across all Linux distributions — Ubuntu, Fedora, Arch, Debian, etc. The terminal is standardized.

However, some distributions might have different default shells. If you use zsh or fish, the commands are identical for listing hidden files.

For zsh, you can also use ls -la or echo .*. The behavior is consistent.

Using Ls With Color On Different Terminals

Some terminals colorize hidden files differently. Use ls --color=auto to enable colors. Hidden files might appear in a different hue.

This visual cue helps you quickly identify hidden items in a long list.

How To See Hidden Files In Linux Terminal For System Administration

System administrators often need to inspect hidden files in /etc, /var, or user home directories. Hidden configuration files control services like SSH, Apache, and cron.

For example, ls -la /etc/ssh shows hidden files like .ssh directory contents. The .ssh directory contains keys and configuration.

Regularly checking hidden files helps maintain system security and troubleshoot issues.

Viewing Hidden Files In Recovery Mode

If your system fails to boot, you can use a live USB and mount the root partition. Then use ls -la to view hidden files in the mounted directory.

This is critical for recovering configuration files or logs.

How To See Hidden Files In Linux Terminal With Less Or More

When you have many hidden files, pipe the output to less or more for paginated viewing.

Run ls -la | less. Use arrow keys or Page Up/Down to scroll. Press q to quit.

This is helpfull when listing large directories like /usr or /var.

Searching Within Less

While viewing with less, type / followed by a pattern to search. For example, /\. finds lines with a dot. This speeds up finding specific hidden files.

This is a pro tip for power users.

How To See Hidden Files In Linux Terminal With Awk And Sed

For advanced filtering, use awk or sed. For instance, ls -la | awk '/^\./' prints lines starting with a dot.

Or ls -la | sed -n '/^\./p' does the same. These commands are usefull in scripts for automated processing.

You can also extract just the filenames: ls -A | awk '/^\./'.

Using Xargs With Hidden Files

To perform actions on hidden files, use xargs. For example, ls -A | grep "^\." | xargs chmod 600 changes permissions of all hidden files to read/write for owner only.

Be careful with xargs — test with echo first.

How To See Hidden Files In Linux Terminal In A Recursive Manner

To see hidden files in all subdirectories, use find as shown earlier. Alternatively, ls -laR recursively lists all files, including hidden ones.

The -R flag stands for recursive. This can produce a lot of output, so use with less.

Example: ls -laR ~/Documents shows everything in that directory tree.

Using Du To See Sizes Of Hidden Directories

The du command shows disk usage. To include hidden directories, use du -sh .*. This shows the size of each hidden item.

For a recursive view, du -sh .[!.]* excludes . and ...

This is usefull for cleaning up disk space.

Frequently Asked Questions

How Do I See Hidden Files In Linux Terminal Using Only The Ls Command?

Use ls -a or ls -A. The -a flag shows all files including . and .., while -A omits them.