{{Short description|File system object that is not displayed by default}} {{Redirect|Dot file|the computer language which uses the .dot extension|DOT (graph description language)}} 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 avoid showing the user files that are not likely to be of interest to them. The feature is not a security mechanism because access is not restricted; the user can request that normally-hidden files be displayed.<ref>{{Cite web|title=What is a hidden file?|url=http://windows.microsoft.com/en-nz/windows/what-is-hidden-file|url-status=dead|archive-url=https://web.archive.org/web/20150403103903/http://windows.microsoft.com/en-nz/windows/what-is-hidden-file#1TC=windows-7|archive-date=2015-04-03|website=Microsoft.com}}</ref><ref>{{man|1|ls|v7}}</ref> Hiding is a feature of the programs that display file system objects, not a feature of file systems or of the operating system as a whole.
== Unix and Unix-like environments == The Unix-based <code>ls</code> shell command hides any file that starts with a dot (commonly called a '''dot file''' or '''dotfile''') unless the option {{code|-a}} or {{code|-A}} is specified. <ref>{{cite web|url=https://linux.die.net/man/1/ls|title=ls(1) - Linux man page|publisher=linux.die.net|access-date=2020-08-23}}</ref> Even with wildcard matching, the command does not match a dotfile unless the expression starts with <code>.</code> For example, {{code|*f*}} does not match {{code|.foo}}, but {{code|.f*}} does.
According to Rob Pike, dotfiles were an unintended consequence of the implementation of the hierarchical file system during the Unix 2nd Edition re-write, which introduced <code>.</code> as a name in a directory that refers to the directory itself and <code>..</code> as a name in a directory that refers to its parent directory. In order to exclude those two entries from <code>ls</code> output, all entries prefixed with <code>.</code> were omitted. This meant that any file or directory could be excluded from the output of <code>ls</code> by giving it a file name with <code>.</code> as the first character.<ref>{{cite web| url=https://plus.google.com/+RobPikeTheHuman/posts/R58WgWwN9jp| title=A lesson in shortcuts.| date=August 3, 2012| publisher=Google Plus |author=Rob Pike | archive-url=https://web.archive.org/web/20141205101508/https://plus.google.com/+RobPikeTheHuman/posts/R58WgWwN9jp| archive-date=2014-12-05| url-status=dead}}</ref>
Commonly, user-specific application configuration information is stored in the user's home directory as a dotfile. Notable dotfiles include startup shell scripts such as <code>.profile</code>, <code>.login</code>, and <code>.cshrc</code> as well as <code>.plan</code> and <code>.project</code> which are used by the <code>finger</code> and <code>name</code> commands.<ref>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 <code>.plan</code> and <code>.project</code> files in that user's <code>$HOME</code> folder.</ref> Many applications, from bash to desktop environments such as GNOME, store user-specific configuration this way, but the ''XDG Base Directory Specification'' aims to migrate such config files to be non-hidden (not starting with {{code|.}}) but stored in a hidden directory <code>$HOME/.config</code>.<ref>{{cite web|url=http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html|title=XDG Base Directory Specification|first1=Waldo|last1=Bastian|first2=Ryan|last2=Lortie|first3=Lennart|last3=Poettering|author-link3=Lennart Poettering|date=November 24, 2010|access-date=June 4, 2014}}</ref>
=== Android === The Android operating system provides empty {{samp|.nomedia}} files as a hint to apps to exclude the content of the folder. This convention prevents photo and music files from appearing 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 freely.
This convention is not enforced by the file or operating systems. Each app is responsible for following the convention.
=== GNOME === thumb|314px|GNOME Files featuring a hidden directory In the GNOME desktop environment (as well as programs using GLib<ref>{{cite web|title=GLib commit: Support for .hidden files| date=28 November 2012 |url=https://git.gnome.org/browse/glib/commit/?id=510ba9b4efe1813e24c6dfa7405c3547bf9efdd7|access-date=2013-08-07}}</ref>), filenames listed in a file named {{samp|.hidden}} are excluded from the directory containing the file. In the file manager, keyboard shortcut {{keypress|Ctrl|H}} includes both dotfiles and files listed in {{samp|.hidden}}.
=== macOS === In addition to the dotfile behaviour, files with the invisible attribute are excluded by Finder although not by <code>ls</code>.
The invisible attribute can be set or cleared via the <code>SetFile</code> command. For example, command line <code>SetFile -a V jimbo</code> hides the file {{mono|jimbo}}.<ref>{{man|1|SetFile|Darwin}}</ref> Starting in Snow Leopard, the <code>chflags</code> command can also be used. For example, <code>chflags hidden jimbo</code> is equivalent.<ref>{{man|1|chflags|Darwin}}</ref>
== Windows and DOS ==
The FAT, NTFS, and ReFS file systems, which have originated from DOS and Windows, maintain two file attributes called "hidden" and "system" for each item. Items with these attributes are hidden.
=== Command Prompt ===
In Windows Command Prompt, the <code>dir</code> command excludes items that have either the "hidden" or "system" attributes. If invoked with the <code>/a</code> command-line switch, the command shows all items, even the hidden ones. Its variations <code>/as</code> and <code>/ah</code> respectively display files with the "system" and "hidden" attributes.
The <code>attrib.exe</code> command-line utility, included will all versions of MS-DOS and Windows, can set or clear attributes.
=== File Explorer ===
File Explorer controls visibility based on user settings that are accessible from its toolbar (or via the Control Panel). By Default, File Explorer excludes items with the "hidden" attribute, but can reveal them if the "Show hidden files, folders, or drives" is set. Items with the "System" attribute remain hidden unless another setting, called "Hide protected operating system files (Recommended)," is cleared. File Explorer renders the icons of hidden items semi-transparently.
A Windows Shell hack allows one to hide the content of a folder by suffixing a pre-defined CLSID to its name.<ref name="guid">{{cite web |title=Canonical Names of Control Panel Items - Win32 apps |url=https://docs.microsoft.com/en-us/windows/win32/shell/controlpanel-canonical-names?redirectedfrom=MSDN |website=Microsoft | date=29 April 2022 |language=en-us}}</ref> The folder is still visible in File Explorer, but its content becomes one of the Windows special folders.<ref>{{cite web |title=The Secret BEHIND the Windows 7 GodMode |url=https://www.thewindowsclub.com/the-secret-behind-the-windows-7-godmode |website=The Windows Club |date=5 January 2010}}</ref> This hack is restricted to File Explorer and Windows Shell API. Any app that doesn't use the Shell API (including the bundled Windows Command Prompt and PowerShell) can see the folder, its name, and its content.
== PowerShell (cross-platform) ==
PowerShell started out as the successor Windows Command Prompt for Microsoft Windows, but is now a cross-platform, free, and open-source shell.
The <code>Get-ChildItem</code> cmdlet, by default, doesn't display hidden items, unless configured to do so via parameters. With the <code>-Force</code> parameter, the cmdlet displays all items, including hidden ones. With the <code>-Hidden</code> parameter, the cmdlet displays only hidden items, excluding ordinary items. The cmdlet also features a <code>-Attributes</code> parameters that allows granular filtering by specific attributes.
The <code>Get-ItemProperty</code> and <code>Set-ItemProperty</code> cmdlets can query or modify the <code>Attributes</code> property of each file or directory.
==References== {{reflist}}
== External links == * Bellevue Linux Users Group: {{webarchive |url=https://web.archive.org/web/20071017224738/http://bellevuelinux.org/hidden_file.html |date=October 17, 2007 |title=Hidden files in Unix-like operating systems }} * Computer Hope: [http://www.computerhope.com/attribhl.htm Microsoft DOS {{mono|attrib}} command] * [https://nomedia.net .NOMEDIA file]
{{Computer files}} {{DEFAULTSORT:Hidden file and hidden directory}} Category:Computer file systems Category:Metadata