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.
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)- A2% (1)
- B4% (2)
- C94% (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.
magic is not a standard Linux command; the magic database is a data file consumed by the file utility, not an executable itself.
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.
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.
pmagic is not a standard Linux utility; no such command exists for file type identification.
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
Community Discussion
No community discussion yet for this question.