Jump to content

Hidden file and hidden directory

From Wikipedia, the free encyclopedia

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. Hiding is a feature of the programs that display file system objects; not inherently with either the operating or file systems.[1][2][3][4]

Unix and Unix-like environments

[edit]

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, dotfiles were an unintended consequence of the implementation of the hierarchical file system during the Unix 2nd Edition re-write, which introduced . as a name in a directory that refers to the directory itself and .. as a name in a directory that refers to its parent directory. In order to exclude those two entries from ls output, all entries prefixed with . were omitted. This meant that any file or directory could be excluded from the output of ls by giving it a file name with . as the first character.[6]

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 .profile, .login, and .cshrc as well as .plan and .project which are used by the finger and name commands.[7] 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 .) but stored in a hidden directory $HOME/.config.[8]

Android

[edit]

The Android operating system provides empty .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

[edit]

In the GNOME desktop environment (as well as programs using GLib[9]), filenames listed in a file named .hidden are excluded from the directory containing the file. In the file manager, keyboard shortcut Ctrl+H includes both dotfiles and files listed in .hidden.

GNOME Files featuring a hidden directory

macOS

[edit]

In addition to the dotfile behaviour, files with the invisible attribute are excluded by Finder although not by ls.

The invisible attribute can be set or cleared via the SetFile command. For example, command line SetFile -a V jimbo hides the file jimbo.[10] Starting in Snow Leopard, the chflags command can also be used. For example, chflags hidden jimbo is equivalent.[11]

Windows and DOS

[edit]

DOS-based file systems, including Windows, maintain a hidden and a system attribute for each item. The attrib command allows for setting and clearing the attributes.

Dir command

[edit]

By default, the dir command excludes items that have either the hidden or system attribute. Option /ah includes hidden items and /as includes system items.

Get-ChildItem cmdlet

[edit]

PowerShell provides similar capability via the Get-ChildItem cmdlet which is aliased as dir. The options are -ah and -as since PowerShell does not use slash for options.

Explorer

[edit]

Windows Explorer controls visibility based on system settings that are accessible via the control panel. Explorer excludes items with the hidden attribute unless the settings allow showing items with the hidden attribute (Show hidden files, folders, or drives is checked). For an item marked with the system attribute, but not the hidden attribute, Explorer includes the item. But, if it also has the hidden attribute, then it is only included if settings allow both showing hidden items and not hiding system files (Hide protected operating system files is unchecked).

Even when excluded from view, an item can be accessed by entering its path in the address bar.

When included, items with the hidden attribute are displayed with transparency to visually indicate the attribute.

The content of a directory can also be hidden 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 actual content can be reteived via the dir command.

References

[edit]
  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.
[edit]