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.
Question
The command used to determine a file's type is
Options
- Atype
- Bfind
- Cfile
- Dls
How the community answered
(40 responses)- A15% (6)
- B8% (3)
- C73% (29)
- D5% (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.
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.
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.
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.
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
Community Discussion
No community discussion yet for this question.