How to Create a Hidden File or Directory in Ubuntu Terminal

If you share a Linux computer with other users, or if you frequently give presentations where your desktop and file manager are projected onto a screen, you might have certain files or folders you prefer to keep out of plain sight. While true security requires encryption and strict permission management, sometimes you just need basic visual privacy to keep a clutter of configuration files or personal documents hidden from casual browsing.

Unlike Windows, which uses a specific “hidden” file attribute buried in a properties menu, Linux handles hidden files in a remarkably simple and elegant way: it is entirely based on the name of the file itself. Any file or directory that begins with a period (.) is automatically hidden by the operating system.

This guide explains how to create, view, and manage hidden files and directories using the Ubuntu terminal.

Step 1: Create a Hidden File

To create a hidden file, you use the exact same commands you would use to create a normal file, but you simply add a dot to the beginning of the filename.

For example, if you want to create a quick, empty hidden text file to store some notes, you would use the touch command:

touch .secret_notes.txt

If you run a standard ls command to view the contents of the directory, you will notice that .secret_notes.txt does not appear in the list. It is completely invisible to standard directory listings and the graphical file manager.

Step 2: Create a Hidden Directory

The exact same rule applies to folders. To create a new, hidden directory to store multiple files, use the mkdir (make directory) command with a leading dot.

mkdir .private_folder

You can now move sensitive files into this directory, and the entire folder will remain hidden from view.

Step 3: Hide an Existing File

What if you have an existing file, like financial_report.pdf, and you decide you want to hide it? You do not need to create a new file; you just need to rename it to include the leading dot. In Linux, renaming and moving are handled by the same command: mv (move).

mv financial_report.pdf .financial_report.pdf

The file instantly vanishes from standard view. To un-hide it later, simply reverse the command, moving it from the dotted name back to the standard name:

mv .financial_report.pdf financial_report.pdf

Step 4: How to View Hidden Files

Because they are hidden, you cannot see these files using a standard ls command. If you forget what you named a hidden file, how do you find it?

You must pass the -a (all) flag to the ls command. This instructs the terminal to show absolutely everything in the directory, regardless of the naming convention.

ls -a

When you run this command, your hidden files (like .secret_notes.txt) will finally appear in the output alongside your regular files.

Pro Tip: If you are using the graphical Ubuntu File Manager (Nautilus) instead of the terminal, you can instantly toggle the visibility of all hidden files by pressing Ctrl + H on your keyboard.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.