Viewing hidden files on Linux is straightforward once you know the correct terminal flag to pass to the ls command. This guide covers exactly how to show hidden files on linux using both command-line and graphical methods.
Hidden files in Linux start with a dot (.) and are concealed by default. They store configuration settings, application data, and system preferences. Knowing how to access them is essential for troubleshooting, customization, and system administration.
Understanding Hidden Files On Linux
Linux treats any file or directory beginning with a period as hidden. This convention keeps your home directory clean and prevents accidental modification of important config files.
Common hidden files include:
- .bashrc – Shell configuration
- .profile – Login environment settings
- .ssh – SSH keys and config
- .gitconfig – Git version control settings
- .local – User-specific application data
These files are not actually secret or encrypted. They are simply not displayed by default when listing directory contents.
How To Show Hidden Files On Linux
The most common method uses the ls command with the -a flag. This stands for “all” and displays every file, including hidden ones.
Using The Ls Command With -A Flag
Open your terminal and type:
ls -a
This shows all files in your current directory, including the special entries . (current directory) and .. (parent directory).
If you want to exclude these two entries, use the -A flag instead:
ls -A
The -A option shows almost all files, omitting only . and ... This is often cleaner for everyday use.
Viewing Hidden Files With Detailed Information
Combine flags for more context. Use -la to show hidden files with permissions, ownership, size, and modification date:
ls -la
For human-readable file sizes, add the -h flag:
ls -lah
This displays sizes in KB, MB, or GB instead of bytes.
Listing Hidden Files Recursively
To see hidden files in subdirectories too, use the -R flag:
ls -laR
This can produce a lot of output. Consider piping it through less for easier navigation:
ls -laR | less
Using The Find Command
The find command offers more control. To locate all hidden files in your home directory:
find ~ -name ".*" -type f
To find hidden directories:
find ~ -name ".*" -type d
You can also search for specific hidden files, like all .bashrc files:
find / -name ".bashrc" -type f 2>/dev/null
The 2>/dev/null suppresses permission errors.
Using Wildcards With Hidden Files
Bash treats hidden files differently with wildcards. The pattern * does not match files starting with a dot. To match them, use:
echo .*
Or list all files including hidden ones with:
echo {*,.*}
This expands to both regular and hidden files.
Showing Hidden Files In File Managers
Most Linux desktop environments provide a graphical way to view hidden files.
GNOME Files (Nautilus)
Press Ctrl + H to toggle hidden files on and off. You can also click the hamburger menu (three lines) and select “Show Hidden Files.”
KDE Dolphin
Press Alt + . (period) or click the “View” menu and check “Show Hidden Files.”
XFCE Thunar
Press Ctrl + H or go to “View” > “Show Hidden Files.”
Other File Managers
Most use Ctrl + H as the standard shortcut. Check the View menu if that doesn’t work.
Creating Hidden Files And Directories
To make a file hidden, simply rename it with a leading dot:
mv myfile .myfile
To create a new hidden file:
touch .hiddenfile
For a hidden directory:
mkdir .hiddendir
Practical Examples
Backing Up Hidden Configuration Files
Copy all hidden files from your home directory to a backup location:
cp -r ~/.* /backup/config/
Be careful with this command as it also copies . and ... Use rsync for safer backups:
rsync -av --exclude='.' --exclude='..' ~/.* /backup/config/
Editing Hidden Configuration Files
Open a hidden file with your preferred text editor:
nano .bashrc
vim .profile
gedit .gitconfig
Removing Hidden Files
Delete a hidden file:
rm .hiddenfile
Remove a hidden directory and its contents:
rm -rf .hiddendir
Always double-check before using rm -rf.
Common Pitfalls And Solutions
Accidentally Deleting Hidden Files
Hidden files are often critical for application settings. Always back up before deleting unknown files.
Permission Denied Errors
Some hidden files require root access. Use sudo when necessary:
sudo ls -la /root
Hidden Files Not Showing In File Manager
If Ctrl + H doesn’t work, check your file manager’s settings or try restarting it.
Advanced Techniques
Using Grep With Hidden Files
Search for text within hidden files:
grep -r "searchterm" ~/.*
This searches all hidden files in your home directory.
Using Alias For Convenience
Create a permanent alias to show hidden files by default. Add this to your .bashrc:
alias ls='ls --color=auto -A'
Then reload the file:
source ~/.bashrc
Now ls will always show hidden files (except . and ..).
Using Tree Command
Display directory structure including hidden files:
tree -a
Install tree if not available:
sudo apt install tree (Debian/Ubuntu)
sudo yum install tree (RHEL/CentOS)
Why Hidden Files Matter
Hidden files store personalization settings, application preferences, and system configurations. Understanding them helps you:
- Troubleshoot software issues
- Customize your environment
- Transfer settings between systems
- Clean up disk space safely
For example, deleting .mozilla removes all Firefox settings. Backing up .ssh preserves your SSH keys.
Security Considerations
Hidden files are not secure. Anyone with terminal access can view them. Never store passwords or sensitive data in hidden files without encryption.
Use proper permissions to protect sensitive hidden files:
chmod 600 .privatefile
This restricts access to the file owner only.
Troubleshooting Common Issues
Ls -A Shows Nothing
Your directory may have no hidden files. Try creating one with touch .test and run ls -A again.
File Manager Not Refreshing
Press F5 or restart the file manager from the terminal.
Hidden Files Appearing As Regular Files
This happens if the file was renamed without a leading dot. Check with ls -la.
Frequently Asked Questions
What is the difference between ls -a and ls -A?
ls -a shows all files including . and ... ls -A shows all files except these two directory entries.
Can I make all files visible permanently in the file manager?
Most file managers remember the setting per session. For GNOME, you can set gsettings set org.gtk.Settings.FileChooser show-hidden true.
How do I show hidden files in a specific directory only?
Navigate to that directory first with cd /path/to/dir, then use ls -a.
Why are hidden files hidden by default?
To reduce clutter and prevent accidental modification of important system and application configuration files.
Can I change the hidden file indicator from a dot to something else?
No, the dot prefix is hardcoded into the Linux filesystem standard. You cannot change it.
Summary
Showing hidden files on Linux is simple with the -a or -A flags for the ls command. File managers use Ctrl + H as a shortcut. Hidden files are essential for system configuration and application settings. Always handle them with care to avoid breaking your setup.
Practice these commands in a test directory first. Create some hidden files, list them, and experiment with different flags. Soon you’ll navigate hidden files with confidence.
Remember that hidden files are not secret. They are simply a organizational convention. Use proper permissions for sensitive data instead of relying on the dot prefix for security.