Hidden Files
There's a secret world in your home directory that ls doesn't show you by default.
What Makes a File Hidden
In Linux, any file or directory starting with . (dot) is hidden:
.bashrc # Hidden
.config/ # Hidden
bashrc # Visible
config/ # Visible
That's it. No special attribute, no hidden flag. Just a dot at the start of the name.
Revealing Hidden Files
The -a flag shows ALL files, including hidden ones.
The . and .. Entries
Every directory contains . (itself) and .. (parent). These are always hidden and always exist.
Why Hidden Files Exist
Hidden files serve two purposes:
- Configuration files - Settings that users rarely need to edit directly
- Clutter reduction - Keeping home directories clean
Without hidden files, your home directory would look like chaos.
Important Hidden Files
Your home directory contains dozens of hidden files. Here are the ones you should know:
| File/Directory | Purpose |
|---|---|
.bashrc | Bash configuration (runs on each terminal) |
.bash_profile | Bash login configuration |
.bash_history | Your command history |
.ssh/ | SSH keys and config |
.gitconfig | Git configuration |
.config/ | Application configs (XDG standard) |
.local/ | User-specific data and binaries |
.cache/ | Application caches |
The .bashrc File
This is probably the most important hidden file. It runs every time you open a terminal:
This is where you add:
- Aliases (shortcuts for commands)
- Environment variables
- Custom prompt settings
- Functions
Customize Carefully
When you edit .bashrc, always keep a backup. A broken .bashrc can make your terminal unusable.
The .ssh Directory
If you use SSH (and you will), this directory is crucial:
~/.ssh/
├── id_rsa # Private key (NEVER share this)
├── id_rsa.pub # Public key (safe to share)
├── known_hosts # Servers you've connected to
└── config # SSH client configuration
Protect Your Private Keys
The ~/.ssh directory should have strict permissions. If it doesn't, SSH might refuse to work:
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_rsa
Creating Hidden Files
Just start the name with a dot:
"Hiding" Existing Files
Rename with a dot prefix:
How do you make a file hidden in Linux?
Key Takeaways
- Files starting with
.are hidden - Use
ls -ato see hidden files - Most hidden files are configs (
.bashrc,.gitconfig, etc.) - The
.ssh/directory contains your SSH keys - protect it - Creating hidden files is as simple as naming them
.something
Next: a tour of the Linux directory structure - where everything lives.