Create a Hidden Directory

Create a Hidden Directory

Sometimes a tool needs several settings files, so a single dot-prefixed file is not enough. A directory such as .school keeps those files together while following the hidden-name convention. Beneath that name, it behaves like the other directories you have already used.

We will put a class setting inside it. This helps you see that hiding applies to the directory's name in a listing, while its children still have their own paths and normal access rules.

What you’ll learn

  • Create and inspect a dot-prefixed settings directory.
  • Keep hidden-name conventions separate from directory access permissions.

The dot changes listing, not the directory tree

  1. Create

    mkdir makes an ordinary directory with a dot-prefixed name.

    .school/
  2. Store

    Files can be created beneath that directory.

    .school/class.txt
  3. Read

    The full path works normally when traversal and file access are permitted.

    class.txt → 10A
A dot-prefixed directory is useful organization, not a new filesystem type.

Store a class setting inside .school

Prepare the example

Begin in a fresh folder with no .school directory. The first line creates the directory before the next command writes its child file. Writing to a path beneath a missing parent would fail, so keep that preparation step in the same example.

Bash · Linux terminal

mkdir .school
printf '10A\n' > .school/class.txt
cat .school/class.txt

Expected result

10A

mkdir .school creates the parent directory. The destination .school/class.txt means the child file named class.txt inside it. printf saves the class value, and the final cat reads that exact path.

A normal listing of the parent may omit .school, but knowing its name lets you refer to it directly. Directory search permission still controls whether a user can traverse to the child, and the child's permissions still govern its content. Hiding the parent does not automatically hide or protect every resource from an authorized user.

Navigate the hidden folder and its children

A hidden directory follows the same naming rule as a hidden file: its name starts with a dot. The directory still works normally; default listings simply leave it out.

Step-by-Step: Creating a Hidden Directory

Let’s start with the basics. Open your terminal, and we’ll create a hidden directory together.

mkdir .my_hidden_folder

What Just Happened?

By adding a dot at the beginning of the folder name, Linux treats it as hidden. If you list files normally with ls, you won’t see it:

ls
Documents  Downloads  Music  Pictures

But if you use the -a flag, it shows all files, including hidden ones:

ls -a
.  ..  .my_hidden_folder  Documents  Downloads

Navigating into a Hidden Directory

You can still use cd to go inside it like any normal folder:

cd .my_hidden_folder

Optional: Creating a Hidden Directory Inside Another One

mkdir -p projects/.config_folder

This creates a hidden directory called .config_folder inside the projects folder. The -p flag ensures the parent directory is created if it doesn't already exist.

Create hidden directories with dot-prefixed names

  • Hidden directories in Linux start with a dot (.)
  • Use ls -a to view them
  • You can enter them with cd just like regular folders

And that’s it! Now you know how to hide your folders like a Linux ninja . Whether you’re organizing config files or just keeping things tidy, hidden directories are a simple and powerful trick.

Try it, then check the worked answer

Your task: Create a dot-prefixed settings directory.

Begin in a fresh folder with no .school directory. The first line creates the directory before the next command writes its child file. Writing to a path beneath a missing parent would fail, so keep that preparation step in the same example.

Bash · complete example for this question

mkdir .school
printf '10A\n' > .school/class.txt
cat .school/class.txt

Expected result

10A

Worked answer

mkdir .school

Use mkdir .school because you need a directory. touch .school would create a regular file instead, and you could not store class.txt beneath it. A name with a dot elsewhere, such as school.hidden, does not follow the leading-dot hidden convention.

Check your decision

Create a dot-prefixed settings directory.
Choose one answer. You can try again.

Answer and explanation

mkdir .school

Use mkdir .school because you need a directory. touch .school would create a regular file instead, and you could not store class.txt beneath it. A name with a dot elsewhere, such as school.hidden, does not follow the leading-dot hidden convention.

A hidden directory still follows normal access rules

A dot-prefixed directory is useful organization, not a new filesystem type. Create the parent first, use the complete child path, and inspect hidden entries when listing. Access control still needs the same deliberate permission choices as a visible directory.

Reaching the recap and completing the quizzes are separate milestones.

    Next lesson: Search the Current Filesystem with find →