LFCS · Question #860
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 is used to determine the type of a file by analyzing its content and comparing it against a predefined database of patterns and magic numbers.
Question
Options
- Amagic
- Btype
- Cfile
- Dpmagic
- Ehash
How the community answered
(30 responses)- B3% (1)
- C93% (28)
- E3% (1)
Why each option
The `file` command is used to determine the type of a file by analyzing its content and comparing it against a predefined database of patterns and magic numbers.
`magic` refers to the database that the `file` command uses for identification, not a standalone command itself.
The `type` command in Bash indicates how the shell interprets a command (e.g., built-in, alias, external program), rather than determining the data type of a file.
The `file` command analyzes the content of a file, including its header and structure, and compares these against a `magic` database (e.g., `/usr/share/misc/magic`) containing definitions for various file types to accurately report its classification.
`pmagic` is not a standard Linux command used for identifying file types.
The `hash` command is used by the shell to manage a hash table of command locations to speed up execution, not to determine the type of a file.
Concept tested: file command for type identification
Source: https://man7.org/linux/man-pages/man1/file.1.html
Topics
Community Discussion
No community discussion yet for this question.