Hidden file

from Wikipedia, the free encyclopedia

A hidden file is a file that is hidden from certain applications in an operating system . This is generally used to increase the overview or to protect against accidental deletion of the operating system's own components.

On directories this applies similarly to. Depending on the term , it means hidden directory and hidden subdirectory or hidden folder and hidden subfolder .

history

Under Unix , hidden files developed out of a hack rather by chance . During the development of the Unix file system, the reserved file names were created as a reference to the current directory and to the higher-level directory for navigation within the directory tree. Because Unix philosophy Everything is a file ( "Everything is a file") follows, and is , and for the system and all programs the same as any other regular file. Directories are usually files under Unix as well. For example, one or any other (sub) directory works with this. However, and that was the problem, it would also be treated as a directory by all other Unix commands, e.g. a. when listing the directory contents with ......cd .cd ..lslisted. Also with all other commands, for examplecp or rm, these apparent directories would be covered by specifying the wildcard * . So in order to remove it again .and ..where it did not make sense, it was quickly filtered out in all commands and in the wildcards - i.e. hidden. To make this resource-saving implement this was a programming trick ( "Hack") with the ease of checking if the file name with a point , run starts.

However, this simplified programming now also made it possible to “hide” other files from all Unix commands. All you need to do is pass the simplified test, which applies to any file name that begins with a period.

Later operating systems, such as MS-DOS and classic Mac OS , added attributes to files, one of which was a file or directory "hidden" in the same way as under Unix.

Technical implementation

There are different concepts of how hidden files are identified by the operating system. The Unix and like Unix operating systems used is, historically given, the identification by the file name itself. So-called "dot files" ( English dot-files ) is displayed with this is that it is a hidden file. In reverse, a hidden file so but is impossible whose name does not begin with a dot. As this logic is integrated into key parts of the operating system itself, it works on all involved volumes , regardless of their format (such as the file system).

Another possibility is metadata in the file system that is evaluated by the operating system (or the file system driver). Attributes are assigned to each file and saved in addition to the file name. However, this means on the one hand that there are correspondingly expanded interfaces and thus requirements for the corresponding file systems for the respective operating system, and on the other hand there must be service programs and functions on the operating system that can manage this metadata. Since almost every operating system has its own file system, these are interwoven and interdependent to manage the metadata.

With the Macintosh from Apple, for example, the file systems HFS and HFS + existed under the classic Mac OS . In both file systems, each file consists of a data fork and a resource fork . While the actual content of the file is saved in the data fork , the resource fork contains metadata, but also resources that can be used by a program in the data fork (e.g. icons , images or other data). In addition, however, the operating system itself manages metadata in the resource fork , such as the - flag of the file. This information is then appropriate programs, primarily the Finder and low-level utilities that manages the file is used by almost all application programs as "invisible" ( English invisible treated) and by default not shown. invisible

PC-compatible DOS such as MS-DOS uses the FAT file system developed by Microsoft , which stores a number of simple attributes in addition to the file name . One is the attribute that is seen in the same way the operating system that the file is "hidden" ( English hidden should be). Most programs generally do not display files marked as hidden. hidden

The designated successors to PC DOS and MS-DOS in the 1990s were OS / 2 from IBM (and initially also Microsoft) and Windows from Microsoft. Both systems initially also used FAT, but due to the various limitations of FAT, they also produced their own file systems: HPFS from OS / 2 and NTFS from Windows NT . The file attributes of FAT have been adopted and expanded so that the “hidden” attribute still exists in these file systems. NTFS is with ADS (for English alternate data streams the function included an alternate data stream that the) Forks corresponds to the Macintosh. However, streams are not used for hidden files .

presentation

Example of view with hidden files.
Example of the option to show hidden files in a menu.

The conventions for how hidden files are handled in an operating system result from the respective technical implementation. These are sometimes adopted by the application programs , but not necessarily. However , these conventions are the default setting for system programs , primarily those supplied by the operating system . An example of this are file managers , which hide files and directories that are hidden by default . However, there is usually an option in the settings that allows the user to show hidden files anyway. In the display, hidden files are usually marked, for example through increased transparency of the symbol , or shown in a different color, for example the file name in gray instead of black.

Under a command line interpreter, files and directories that are hidden by default are also not listed with the command for listing the files. This is e.g. B. the case lswith Unix and Unix-like operating systems. The command dirunder DOS also behaves like this. By specifying a command line parameter , it is possible to include hidden files and directories in the list, for example with ls -aor dir /a.

Applications

For various functions in the operating system, hidden files are usually not recorded, such as copy and move actions. This applies to the command line as well (eg. As cp, mv, rsyncetc. Unix operating systems), where use of *a wildcard does not include all files and directories in a source directory that start with a point hidden files and folders, as well as the graphical User interface where only visible elements can be marked . Hidden files are therefore not recorded (in the standard setting) and therefore, e.g. B. when dragging and dropping , not copied or moved.

When selecting a directory that is copied or moved recursively, however, the hidden files in it are also transferred.

Hidden files are used for different purposes and this is generally a decision of the software developer. There are numerous different examples:

  • System files: With some operating systems, files that are managed by the system and that should not be used directly by the user are hidden. An example are the start files of PC DOS or MS-DOS , IBMBIO.COM or IO.SYS as well as IBMDOS.COM/ MSDOS.SYS and COMMAND.COM . These three start files can be found on each start disk, but they are not normally copied. On the other hand, if you want to make a floppy disk bootable, there is a command SYSthat not only copies these three files and sets the appropriate file attributes, but also writes the boot sector (with FAT: VBR ).
  • Temporary files and directories: Some programs and operating systems generate data from existing files and use them to create files for a kind of intermediate storage, which can a. serves to accelerate. To prevent these temporary files from appearing in the file manager, they are often hidden. In many cases they can be safely deleted, since the data can be generated again at any time, but many programs manage temporary files independently and often offer configuration options for deleting or limiting these files.
  • System functions integrated in the operating system often use hidden (and protected) files and directories. One example is the Windows Recycle Bin , whose files are kept in the hidden (and protected) folder $RECYCLE.BIN. In macOS, the folder is called the trash .Trashes, while the indexes for the Spotlight search function are cached in the hidden folder .Spotlight(temporary files).
  • Configuration files : On Unix and Unix-like operating systems, configuration files for the local user are almost always point files. This makes the user directory , $HOMEor ~and mostly , tidier. However, if you delete these files, you will lose important settings in the relevant programs./home/Benutzername

Examples

On Unix systems, a file is hidden by simply renaming it. To create a hidden file you can e.g. B. the following command can be used:

touch .versteckte_Datei.txt

The file .versteckte_Datei.txtcan be used like any other file, e.g. edited in a text editor :

nano .versteckte_Datei.txt

However, the file is usually not displayed in the listing, except with the parameter -a(lower case a).

ls -a

In order to show lsall hidden files with , but still hide .and ..hide the reserved file names , there is the parameter -A(capitalized A) in modern ls implementations .

If all files are now *.*copied from the current directory with the wildcard , the file .versteckte_Datei.txtand all other hidden files (and directories) are not copied:

cp *.* /Pfad/zum/Ziel

This also applies to the restriction on file name extensions , e.g. only text files with the wildcard *.txt.

Under PC-compatible DOS such as MS-DOS , the ATTRIB command can display, set or delete the file attributes, including "hidden".

attrib Datei.Ext

Even under DOS, hidden files are not contained in the wildcard *.*. In order to be able to copy hidden files anyway, it may be necessary to clear the corresponding flag before copying:

attrib -h Datei.Ext

After the copying process, the English hidden flag should be set again, depending on the project, also for the target file:

attrib +h Datei.Ext
cd \Pfad\zum\Ziel\des\Kopierens\
attrib +h Datei.Ext

Alternatively, there are commands or command line parameters or programs that can also include hidden files. This is especially essential when backing up data . An example of this is the backup utility rsync , or under DOS, for example, xcopy .

In graphical file managers - such as the Explorer of Windows , the finder of macOS , Dolphin of Plasma ( KDE , up to version 3 yet Konqueror ) or Nautilus of Gnome - there is this a view option, generally hidden files enabled the (global) . Depending on the special environment, for example in Nautilus, a certain key combination can also enable the display that only affects the current window, but there are also settings that switch the display of hidden files operating system-wide, for example in Windows Explorer or the Finder of macOS. Hidden files are then also displayed on the desktop .

In the Finder, the attribute stored in the resource fork is evaluated under classic Mac OS, i.e. Mac OS up to version 9 . Since this is stored in the file system, this alternative data stream is also taken into account under Mac OS X, which is actually a BSD- based Unix operating system.

compatibility

In principle, the various technical implementations of the respective operating systems are not compatible with one another. This is always evident in practice when data is to be exchanged on foreign file systems and on the different systems.

It is Z. For example, on FAT file systems that do not support long file names, it is impossible for a file to begin with a period. In the File Allocation Table (FAT) only the file names are saved without a period, the period is automatically placed in front of the file name extension. In addition, all files must follow the 8.3 convention and must not have more than one point.

So if Unix tries to create a hidden file on a FAT file system, it fails because it is not compatible. Compatibility layers such as UMSDOS could help, but they were dependent on the operating system that UMSDOS implemented (Linux only, not every Unix).

On more modern file systems, but also on FAT with the extension VFAT , dot files can be created without problems and are then automatically hidden on all Unix-like operating systems. However, if the file system driver does not set the attribute “hidden” or “invisible” at the same time, then the same file is suddenly visible on operating systems without the Unix convention.

As an example for illustration: If you create the file on a FAT12 floppy disk with VFAT extension (long file names) under MS-DOS HIDDEN.TXTand hide it, it will still be listed under Linux (i.e. it is not hidden):

MS-DOS:
A:\>copy NUL: HIDDEN.TXT
A:\>dir
HIDDEN.TXT
1 Dateien
A:\>attrib +h HIDDEN.TXT
A:\>dir
0 Dateien
Linux:
% touch .hidden.txt
% ls
HIDDEN.TXT
% ls -a
.  ..  .hidden.txt  HIDDEN.TXT

The actually hidden file with the FAT attribute "hidden",, HIDDEN.TXTis displayed under Linux because it is not a point file. The point file, on the other hand, is hidden, although it lacks the FAT attribute.

MS-DOS:
A:\>dir
.hidden.txt
1 Dateien

Under DOS, the file .hidden.txtis listed as visible because point files are not automatically hidden in DOS; Only the “hidden” attribute is decisive, not the file name.

There are mostly similar difficulties on network drives.

Individual evidence

  1. ^ Mark Thomas: Introduction to the Unix File System. In: Introduction to UNIX. Retrieved on May 29, 2020 (English): "From the beginners perspective, the Unix file system is essentially composed of files and directories. Directories are special files that may contain other files. "
  2. Michael Boelen: Linux History: How Dot Files Became Hidden Files. ( Blog ) In: Linux Audit. April 30, 2017, accessed May 7, 2020 .