nerdexam
LPI

010-100 · Question #60

The command used to determine a file's type is

The correct answer is C. file. The file command inspects a file's contents and magic bytes to determine and report its type, regardless of its name or extension.

Finding Your Way on a Linux System

Question

The command used to determine a file's type is

Options

  • Atype
  • Bfind
  • Cfile
  • Dls

How the community answered

(40 responses)
  • A
    15% (6)
  • B
    8% (3)
  • C
    73% (29)
  • D
    5% (2)

Why each option

The file command inspects a file's contents and magic bytes to determine and report its type, regardless of its name or extension.

Atype

The type command is a shell built-in that identifies how the shell interprets a given name - whether it is an alias, function, built-in, or external binary - not the type of a file's contents.

Bfind

The find command searches the filesystem for files matching criteria such as name or permissions but does not analyze or report the content type of a file.

CfileCorrect

The file command reads the beginning of a file and compares it against a database of magic number signatures to identify its type - such as ELF executable, ASCII text, JPEG image, or shell script. It does not rely on the file extension, making it reliable for identifying files with missing or misleading names. This makes it the correct and purpose-built utility for determining what a file actually contains.

Dls

The ls command lists directory contents and can show metadata such as permissions and size but does not inspect or report the internal content type of a file.

Concept tested: Using the file command to identify file type

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

Topics

#file command#file type detection

Community Discussion

No community discussion yet for this question.

Full 010-100 Practice