Hiding files and folders in Linux reduces clutter in home directories and working trees, especially when configuration data or temporary artifacts do not need to appear in every listing. The same mechanism also keeps sensitive dotfiles from casual viewing while still leaving them fully accessible to tools that depend on them.

Instead of filesystem attributes, Linux uses a simple naming convention: any entry whose name begins with a dot character (.) is considered hidden. Shell globs such as * and default directory listings skip these names, so commands like ls and many graphical file managers omit them unless explicitly instructed to show hidden entries. This convention applies uniformly to both regular files and directories.

The dot-prefix mechanism does not provide security, because hidden entries remain readable to anyone with permission and can still be accessed directly by name. Renaming files can also affect scripts or services that expect exact paths, so care is required when hiding or unhiding configuration directories. For consistent behavior across tools, the most reliable method is to rename the file or folder with or without the leading dot and then confirm visibility using ls or a file manager.

Steps to hide and unhide files and folders in Linux:

  1. Open a terminal session in Linux.
    $ whoami
    root
  2. Create a directory named hide-demo for sample files and folders.
    $ mkdir -p /root/sg-work/hide-demo
  3. Populate hide-demo with a regular file and a subdirectory named folder for demonstration.
    $ touch /root/sg-work/hide-demo/file
    $ mkdir -p /root/sg-work/hide-demo/folder
  4. List visible entries in hide-demo before hiding anything.
    $ ls /root/sg-work/hide-demo
    file
    folder
  5. Hide the regular file by renaming it with a dot prefix.
    $ mv /root/sg-work/hide-demo/file /root/sg-work/hide-demo/.file

    Any name that starts with a dot, such as .file or .config, is treated as hidden by most Linux tools.

  6. Confirm that the renamed file no longer appears in a normal listing of hide-demo.
    $ ls /root/sg-work/hide-demo
    folder
  7. Show all entries in hide-demo, including hidden ones, with the --all option to ls.
    $ ls --all /root/sg-work/hide-demo
    .
    ..
    .file
    folder

    The --all (or -a) flag instructs ls to include entries whose names begin with a dot; many graphical file managers follow the same rule and use Ctrl+H to toggle visibility.

  8. Hide the folder by renaming it with a leading dot in the same way.
    $ mv /root/sg-work/hide-demo/folder /root/sg-work/hide-demo/.folder

    Applications or scripts that rely on the original folder name may fail after it is renamed, so update any configuration paths that reference it.

  9. Unhide the file and folder by removing the dot from their names.
    $ mv /root/sg-work/hide-demo/.file /root/sg-work/hide-demo/file
    $ mv /root/sg-work/hide-demo/.folder /root/sg-work/hide-demo/folder
  10. Verify that only visible names remain in the hide-demo directory after unhiding.
    $ ls /root/sg-work/hide-demo
    file
    folder