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:
- Open a terminal session in Linux.
$ whoami user
- Create a directory named temp for sample files and folders.
$ mkdir -p temp
- Populate temp with a regular file and a subdirectory named folder for demonstration.
$ touch temp/file $ mkdir -p temp/folder
- List visible entries in temp before hiding anything.
$ ls temp/ file folder
- Hide the regular file by renaming it with a dot prefix.
$ mv temp/file temp/.file
Any name that starts with a dot, such as .file or .config, is treated as hidden by most Linux tools.
- Confirm that the renamed file no longer appears in a normal listing of temp.
$ ls temp/ folder
- Show all entries in temp, including hidden ones, with the --all option to ls.
$ ls --all temp/ . .. .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.
- Hide the folder by renaming it with a leading dot in the same way.
$ mv temp/folder temp/.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.
- Unhide the file and folder by removing the dot from their names.
$ mv temp/.file temp/file $ mv temp/.folder temp/folder
- Verify that only visible names remain in the temp directory after unhiding.
$ ls temp/ file folder
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.
Comment anonymously. Login not required.
