Linux Administration
medium

Questão de Linux Administration #019e3987

Enunciado da Questão
Linux Administration
#file
#magic
#database
#file-type
Médio

E.

PATHRC

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?

A

magic

B

type

C

file

Correta
D

pmagic

E

hash

Explicação Oficial / Explicações da Comunidade

Summary

The question asks which command uses a definition database file containing information about common file types to determine a file's type. The correct answer is file. The file command reads a file's magic numbers (signatures) and compares them against a database (typically /usr/share/misc/magic or /etc/magic) to identify the file type.

How it Works

The file command performs a series of tests on a file: filesystem tests (checking stat structure), magic number tests (checking for patterns in the file's content), and language tests (for text files). The magic number tests rely on a database file that contains rules for identifying file types based on byte sequences at specific offsets. This database is compiled from source files like /etc/magic or /usr/share/misc/magic.

Why the correct answer is right

  • C. file: The file command is specifically designed to determine file type using a magic database. It reads the file's content and matches it against known signatures.

Why incorrect options are wrong

  • A. magic: There is no standard command named magic. The term refers to the database file, not a command.
  • B. type: type is a shell builtin that shows how a command would be interpreted (alias, function, builtin, or disk file). It does not determine file types.
  • D. pmagic: Not a standard Linux command. Possibly a typo or unrelated.
  • E. hash: hash is a shell builtin that manages the command hash table. It does not determine file types.