Hide and Unhide Files on Linux: A Practical Guide
To hide a file or folder in Linux, rename it so its name begins with a dot (e.g., mv report.txt .report.txt). To unhide it, rename it back without the leading dot, or use the -a flag with ls to see hidden files in place.
Why Dotfiles Are the Standard
Linux and other Unix-like systems treat any file or directory whose name starts with a period as hidden. This convention dates back to early Unix, where the . and .. entries (current and parent directory) were simply not shown by ls to reduce clutter. Over time, the shell and file managers extended this behavior to any dot-prefixed name.
Hidden files are not secret or encrypted—they are just not displayed by default. Any program or user can view them if they know the name or use the right flags. This is a convenience feature, not a security mechanism.
How to Hide a File or Folder
The simplest method is renaming with the mv command:
mv notes.txt .notes.txt
For a folder:
mv myfolder .myfolder
You can also hide multiple files at once using a loop or by moving them into a hidden directory. For example, to hide all .log files in the current directory:
for f in *.log; do mv "$f" ".$f"; done
In graphical file managers like Nautilus (GNOME Files), Dolphin (KDE), or Thunar, press Ctrl+H to toggle the display of hidden files, then right-click a file and select “Rename” to add or remove the dot.
How to Unhide a File or Folder
To unhide, rename it back to a name without the leading dot:
mv .notes.txt notes.txt
If you want to keep the hidden name but see it in listings, use the -a (all) flag with ls:
ls -a
This shows every entry, including . and ... To see hidden files with details like permissions and size, use ls -la. In a file manager, pressing Ctrl+H again will toggle hidden files back on.
Viewing Hidden Files in the Terminal
Beyond ls -a, there are other ways to work with hidden files:
ls -A– lists all entries except.and.., which is often cleaner.find . -name ".*"– finds all hidden files recursively from the current directory.echo .*– prints a list of hidden entries in the current directory.grep -r "pattern" .– searches inside hidden files too, because.includes them.
If you want to open a hidden file in a text editor, just type its full name:
nano .bashrc
Tab completion works as usual—type .b and press Tab to complete .bashrc.
Common Mistakes and Misconceptions
One frequent mistake is assuming that hiding a file makes it invisible to other users or protects it from deletion. Hidden files are still readable, writable, and deletable by anyone with the appropriate permissions. If you need privacy, use encryption (e.g., gpg) or proper file permissions (chmod).
Another misconception is that you can hide a file by setting a special attribute. Linux does have the chattr command, but its attributes (like +i for immutable) do not hide files from listing—they only prevent modification or deletion. There is no built-in “hidden” attribute like in Windows.
Also, be careful when renaming files that start with a dot: some programs rely on specific dotfile names (e.g., .bashrc, .gitconfig). Renaming them can break your shell configuration or version control settings.
Hidden Files in Different File Managers
Most Linux file managers follow the same rule: a leading dot hides the file. However, the shortcut to toggle visibility varies:
- GNOME Files (Nautilus): Ctrl+H
- KDE Dolphin: Ctrl+H or the menu View → Show Hidden Files
- XFCE Thunar: Ctrl+H
- Linux Mint Caja: Ctrl+H
If a file manager doesn’t respond to Ctrl+H, look for a “Show Hidden Files” option in the View menu or the toolbar’s hamburger menu.
Alternatives to Dotfile Hiding
If you need to hide files from other users or protect them from accidental deletion, consider these alternatives:
- Permissions: Use
chmod 600 fileto make it readable only by you. This does not hide it, but it prevents others from opening it. - Encryption: Use
gpg -c fileto encrypt a file with a passphrase. The resultingfile.gpgis unreadable without the key. - Move to a private directory: Put sensitive files in a directory outside your home (e.g.,
/opt/private) and restrict permissions withchmod 700. - Use a password manager: For credentials, use a dedicated tool like KeePassXC or Bitwarden instead of hiding a text file.
Remember that hiding is about reducing clutter, not security. For real confidentiality, combine permissions and encryption.
Frequently Asked Questions
How do I see hidden files in the terminal?
Use ls -a to list all files including hidden ones. For more detail, use ls -la (long format). To see only hidden files, you can use ls -d .*.
Can I hide a file without renaming it?
No, the only standard way to hide a file from normal listings is to start its name with a dot. There is no hidden attribute in the Linux filesystem. You can, however, create a hidden directory and move the file inside it.
Why do some hidden files have two dots like ..?
The .. entry is the parent directory, and . is the current directory. They are not actual files you created; they are special filesystem entries. ls -a shows them, but ls -A omits them.
Does hiding a file affect its permissions?
No, renaming does not change permissions. A hidden file retains its original read/write/execute permissions. If you want to restrict access, use chmod separately.
How do I unhide a file if I forgot its name?
Use ls -a to list all files, then look for entries starting with a dot. If you have many, use find . -name ".*" -type f to list only hidden files.
Can I hide files on a USB drive or external disk?
Yes, the dotfile convention works on any filesystem that Linux can write to, including ext4, NTFS, and FAT32. However, Windows will not hide those files; it uses its own hidden attribute. If you share the drive with Windows, consider using a different method.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.