Updated: 3 November 2026 · Applies to: Linux, any shell and most desktop file managers

To hide a file or directory in Linux, rename it so its name starts with a dot. Linux treats any name beginning with . as hidden, and both the terminal and graphical file managers skip it in normal directory listings unless you explicitly ask to see hidden files too.

Hide a file from the terminal

Use mv to rename the file with a leading dot:

mv notes.txt .notes.txt

List the directory normally and the file is gone from view, even though it is still right there:

ls

This works exactly the same way for a directory, not just a single file:

mv old-project .old-project

View hidden files again

Add -a to ls to show every file, hidden ones included:

ls -a

Combine it with -l for a detailed, long format listing of everything, hidden files included:

ls -al

In most graphical file managers, press Ctrl+H, or open the View menu and enable Show Hidden Files, to see the same dotted files there.

Why this is convention, not security

A leading dot only changes what a normal directory listing shows by default; it does not restrict who can open the file. Anyone who already has permission to read that directory, including ls -a, find, or simply typing the exact filename, can see and open it exactly as before. It is a tidiness convention Linux itself relies on heavily, for example .bashrc and .ssh in your own home directory, not an access control.

If a file genuinely needs to be kept from other users on the same system, set its permissions instead:

chmod 600 notes.txt

600 means only the file's owner can read or write it; everyone else gets no access at all. For something you want to actively protect from accidental changes, including by your own account, chattr can mark a file immutable so even the owner cannot modify or delete it until the flag is removed:

chattr +i important-config.conf

Remove the flag the same way, with a minus instead of a plus, once you need to edit the file again:

chattr -i important-config.conf

Related services

KVM VPS hosting

NVMe SSD and full root access, with Free Basic Managed Support.

Unmanaged dedicated servers

full root access and free IPMI KVM, with Free Basic Managed Support.

Managed dedicated servers

our engineers look after the server for you, from $135 a month.

Was this answer helpful?

Still stuck? Open a ticket