Jump to content

Hidden file and hidden directory

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Stevebroshar (talk | contribs) at 18:42, 23 April 2025 (Unix and Unix-like environments: The story is more about 'ls' (commands/utilities) than operating system or file system). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

In computing, a hidden file or hidden directory is a file system object (such as a file or directory) that is excluded from a directory content report unless explicitly requested. The value of hiding files is generally to reduce cognitive load by excluding files that a user may not have created directly or is less likely to access directly. The feature is not a security mechanism because access is not restricted; just requires explicit request.[1][2][3][4]

Unix and Unix-like environments

The Unix-based ls shell command hides any file that starts with a dot (commonly called a dot file or dotfile) unless the option -a or -A is specified. [5] Even with wildcard matching, the command does not match a dotfile unless the expression starts with . For example, *f* does not match .foo, but .f* does.

According to Rob Pike, the dotfile was an unintended consequence of the implementation of the hierarchical file system during the Unix 2nd Edition re-write, which introduced . to denote a directory based on context and .. for its parent directory. In order to exclude those two entries from ls output, all entries prefixed with . were omitted. This introduced a general mechanism for hidden files.[6]

A convention arose of using dotfiles in the user's home directory to store per-user configuration or informational text. Early uses of this were the well-known dotfiles .profile, .login, and .cshrc, which are configuration files for the Bourne shell and C shell and shells compatible with them, and .plan and .project, both used by the finger and name commands.[7]

Many applications, from bash to desktop environments such as GNOME, now store their per-user configuration this way, but the Unix/Linux freedesktop.org XDG Base Directory Specification aims to migrate user config files from individual dotfiles in $HOME to non-hidden files in the hidden directory $HOME/.config.[8]

Android

The Android operating system uses empty .nomedia files to tell smartphone apps not to display or include the contents of the folder. This prevents digital photos and digital music files from being shown in picture galleries or played in MP3 player apps. This is useful to prevent downloaded voicemail files from playing between the songs in a playlist, and to keep personal photos private while still allowing those in other folders to be shared in person with friends, family, and colleagues. The .nomedia file has no effect on the filesystem or even the operating system, but instead depends entirely on each individual app to respect the presence of the different files.

GNOME

In the GNOME desktop environment (as well as all programs written using GLib[9]), filenames listed in a file named .hidden in each directory are also excluded from display. In GNOME's file manager, the keyboard shortcut Ctrl+H enables the display of both kinds of hidden files.

GNOME Files featuring a hidden directory

macOS

In addition to the "dotfile" behaviour, files with the "Invisible" attribute are hidden in Finder, although not in ls. The "Invisible" attribute can be set or cleared using the SetFile command; for example, invoking SetFile -a V jimbo will hide the file jimbo.[10] Starting in Mac OS X Snow Leopard, the chflags command can also be used; for example, chflags hidden jimbo will hide the file jimbo.[11]

DOS and MS Windows

In DOS systems, file directory entries include a Hidden file attribute which is manipulated using the attrib command. Using the command line command dir /ah displays the files with the Hidden attribute. In addition, there is a System file attribute that can be set on a file, which also causes the file to be hidden in directory listings. Use the command line command dir /as to display the files with the System attribute.

Under Windows Explorer, Hidden files and directories are, by default, not displayed - though they are still accessible by entering the full path into the explorer address bar. System files are displayed, unless they are also hidden. There are two options that enable the display of hidden files. The main "Hidden files and folders" option can be used to turn on the display of hidden files but this won't, on its own, display hidden system files. A second option, "Hide protected operating system files" additionally needs to be turned off in order for hidden system files to be shown. Hidden files are displayed with a slight transparency, so even when they are visible they are visually delineated from non-hidden files.

Under Windows Explorer, the content of a directory can also be hidden just by appending a pre-defined CLSID[12] to the end of the folder name. The directory is still visible, but its content becomes one of the Windows Special Folders.[13] However, the real content of this directory can still be seen using the CLI command dir.

References

  1. ^ "What is a hidden file?". Microsoft.com. Archived from the original on 2015-04-03.
  2. ^ "Configuring X: What are all those dotfiles for anyway?". Linux Focus. March 1998. Retrieved 2013-09-08.
  3. ^ "Sample .bashrc and .bash_profile Files". Linux Documentation Project.
  4. ^ Subodh Soni (2001-12-01). "Understanding Linux configuration files". IBM Developer. Retrieved 2019-04-26.
  5. ^ "ls(1) - Linux man page". linux.die.net. Retrieved 2020-08-23.
  6. ^ Rob Pike (August 3, 2012). "A lesson in shortcuts". Google Plus. Archived from the original on 2014-12-05.
  7. ^ One user could lookup another by using the command along with the username (and hostname if not on the local host), and the finger service would respond with the other user's current status, and the contents of the .plan and .project files in that user's $HOME folder.
  8. ^ Bastian, Waldo; Lortie, Ryan; Poettering, Lennart (November 24, 2010). "XDG Base Directory Specification". Retrieved June 4, 2014.
  9. ^ "GLib commit: Support for .hidden files". 28 November 2012. Retrieved 2013-08-07.
  10. ^ SetFile(1) – Darwin and macOS General Commands Manual
  11. ^ chflags(1) – Darwin and macOS General Commands Manual
  12. ^ "Canonical Names of Control Panel Items - Win32 apps". Microsoft. 29 April 2022.
  13. ^ "The Secret BEHIND the Windows 7 GodMode". The Windows Club. 5 January 2010.