In computing, ".bak" is a filename extension commonly used to signify a backup copy of a file.
Is there any other significance of a .bak file in UNIX apart from changing the extension to .bak?
In computing, ".bak" is a filename extension commonly used to signify a backup copy of a file.
Is there any other significance of a .bak file in UNIX apart from changing the extension to .bak?
In Unix, file extensions are simply used as a visual cue so that people can more easily identify what application to use for a given type of file with extension .xxx or .yyy.
In terms of the OS, extensions serve no real purpose, rather the kernel may use file signatures for files that it's concerned with, for example, the shebang #!
, but otherwise, it's rather oblivious to file hex signatures.
NOTE: Regarding hex signatures, they're prefixes (in hex) at the beginning of every file. See this Wikipedia articled titled: List of file signatures for some examples.
These prefixes are sometimes also referred to as magic numbers - Magic Number Definition.
A magic number is a number embedded at or near the beginning of a file that indicates its file format (i.e., the type of file it is). It is also sometimes referred to as a file signature.
Magic numbers are generally not visible to users. However, they can easily be seen with the use of a hex editor, which is a specialized program that shows and allows modification of every byte in a file.
For common file formats, the numbers conveniently represent the names of the file types. Thus, for example, the magic number for image files conforming to the widely used GIF87a format in hexadecimal (i.e., base 16) terms is 0x474946383761, which when converted into ASCII is GIF87a. ASCII is the de facto standard used by computers and communications equipment for character encoding (i.e., associating alphabetic and other characters with numbers).
Here I'm using the hexdump
command to look at the headers of files.
jpeg - ff d8
$ hexdump -C simplelock.jpg | head -1
00000000 ff d8 ff e0 00 10 4a 46 49 46 00 01 02 00 00 64 |......JFIF.....d|
gz - 1f 8b
$ hexdump -C rdjpgcom.1.gz | head -1
00000000 1f 8b 08 00 00 00 00 00 02 03 65 55 c1 72 22 37 |..........eU.r"7|
NOTE: For more on how the OS determines a file's type based on these magic numbers & hex signatures see this U&L Q&A titled: How are file types known if not from file suffix? which explains how the command line tool file
works and the process it uses to identify a file's type.
The signature mechanism utilized in Unix is really more of a best effort. The job of tracking associations relies on a fairly archaic set of patterns that have been developed and built up over time to identify a file's type. It's imperfect, and so the responsibility of knowing which file goes with which application is left primarily as exercise to the user.
No, this is just a convention. The contents of the files with such extension have no normalization. It is a mnemonic to aid a human user to identify that those files should not be removed. Many times it happens cause its contents can be hard to understand as mentioned about the lack of a defined structure.
~
.
– Kusalananda
Aug 21 '18 at 10:13