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

Terminal
$ls
Documents Downloads projects
$ls -a
. .. .bashrc .config .ssh Documents Downloads projects

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:

  1. Configuration files - Settings that users rarely need to edit directly
  2. 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/DirectoryPurpose
.bashrcBash configuration (runs on each terminal)
.bash_profileBash login configuration
.bash_historyYour command history
.ssh/SSH keys and config
.gitconfigGit configuration
.config/Application configs (XDG standard)
.local/User-specific data and binaries
.cache/Application caches
Terminal
$ls -la ~
drwxr-xr-x 15 user user 4096 Jan 14 10:00 . drwxr-xr-x 3 root root 4096 Jan 14 08:00 .. -rw------- 1 user user 5432 Jan 14 09:30 .bash_history -rw-r--r-- 1 user user 220 Jan 14 08:00 .bash_logout -rw-r--r-- 1 user user 3771 Jan 14 08:00 .bashrc drwx------ 4 user user 4096 Jan 14 10:00 .config drwx------ 2 user user 4096 Jan 14 09:00 .ssh drwxr-xr-x 2 user user 4096 Jan 14 10:00 Documents drwxr-xr-x 2 user user 4096 Jan 14 10:00 Downloads

The .bashrc File

This is probably the most important hidden file. It runs every time you open a terminal:

Terminal
$head -20 ~/.bashrc
# ~/.bashrc: executed by bash(1) for non-login shells. # If not running interactively, don't do anything case $- in *i*) ;; *) return;; esac # don't put duplicate lines in the history HISTCONTROL=ignoreboth ...

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:

hljs bash
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_rsa

Creating Hidden Files

Just start the name with a dot:

Terminal
$touch .secret
$ls
Documents Downloads
$ls -a
. .. .secret Documents Downloads

"Hiding" Existing Files

Rename with a dot prefix:

Terminal
$mv notes.txt .notes.txt
$ls
Documents Downloads
$ls -a | grep notes
.notes.txt
Knowledge Check

How do you make a file hidden in Linux?

Key Takeaways

  • Files starting with . are hidden
  • Use ls -a to 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.