nerdexam
CompTIA

LX0-103 · Question #47

Which of the following commands determines the type of a file by using a definition database file which contains information about all common file types?

The correct answer is C. file. The file command identifies a file's type by consulting the magic database, which contains byte-pattern signatures for common file formats.

GNU and Unix Commands

Question

Which of the following commands determines the type of a file by using a definition database file which contains information about all common file types?

Options

  • Amagic
  • Btype
  • Cfile
  • Dpmagic
  • Ehash

How the community answered

(52 responses)
  • A
    2% (1)
  • B
    4% (2)
  • C
    94% (49)

Why each option

The file command identifies a file's type by consulting the magic database, which contains byte-pattern signatures for common file formats.

Amagic

magic is not a standard Linux command; the magic database is a data file consumed by the file utility, not an executable itself.

Btype

type is a shell builtin that reports whether a name is a shell function, builtin, alias, or external command - it does not inspect file content.

CfileCorrect

The file utility reads a file's content and compares it against the magic database (typically /usr/share/misc/magic or /etc/magic) to determine its type without relying on the file extension. It reports types such as ELF executable, ASCII text, JPEG image, etc., based on these byte-level signatures.

Dpmagic

pmagic is not a standard Linux utility; no such command exists for file type identification.

Ehash

hash is a shell builtin that manages the shell's command-location cache and has nothing to do with identifying file types.

Concept tested: file command and magic database file type detection

Source: https://man7.org/linux/man-pages/man1/file.1.html

Topics

#file command#file type detection#magic database

Community Discussion

No community discussion yet for this question.

Full LX0-103 Practice