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?

  • 2
    Extensions are essentially meaningless in Unix, they're just visual queues for people. – slm Aug 21 '18 at 4:02
  • Thanks. Does it have to do anything with file archiving or space reclamation? – Nik Aug 21 '18 at 4:36
  • 1
    No, the extensions are completely cosmetic. Files have what is called a magic number in their headers which tells the system what type of file it is. The extension doesn't really play into this - linfo.org/magic_number.html. Covered in more depth here - en.wikipedia.org/wiki/List_of_file_signatures. – slm Aug 21 '18 at 4:40

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.

File signatures in practice

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.

  • Thanks. Does it have to do anything with file archiving or space reclamation? – Nik Aug 21 '18 at 4:21
  • 1
    @Nik No, not at all. – dr01 Aug 21 '18 at 8:36
  • 1
    @Nik It's just a filename suffix. There is no meaning attached to it other than providing a way for a human to identify files that are backups of other files. Another common backup filename suffix is ~. – Kusalananda Aug 21 '18 at 10:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.