The study guide LPIC-1 Training and Preparation Guide (Ghori Asghar, ISBN 978-1-7750621-0-3) contains the following question ...

Which of the following commands can be used to determine the file type?

  • (A) file
  • (B) type
  • (C) filetype
  • (D) what

... and claims that the answer is: "(B) type".

But isn't "(A) file" the correct answer?

I'm beginning to doubt the entire book.

  • 11
    I have to say, a book which starts by saying “the exams are based on RHEL and Debian, so let’s use CentOS and Ubuntu” doesn’t inspire confidence! Mar 13, 2018 at 8:42
  • You should contact the author and notify him of the mistake.
    – dr_
    Mar 13, 2018 at 9:48

2 Answers 2


Yes it seems like your book is wrong.

The file command tells what kind of file it is. From the man file: "file -- determine file type".
A few examples:

$  file /usr/bin/file
/usr/bin/file: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=ecc4d67cf433d0682a5b7f3a08befc45e7d18057, stripped
$ file activemq-all-5.15.0.jar
activemq-all-5.15.0.jar: Java archive data (JAR)

The type command is used to tell if a command is built in or external:

$ type file
file is /usr/bin/file
$ type type
type is a shell builtin
  • 6
    type is a builtin on most shells, which tells us what something that can be executed is (builtin, alias, function, executable, etc.). In your case it's saying there's no test.sh that can be executed (either in PATH, or as a builtin/function/alias, etc.).
    – muru
    Mar 13, 2018 at 6:05
  • You're absolutely right. I never knew that. Doesn't change the answer should be file though. I'll update my answer. Mar 13, 2018 at 6:15
  • Thank you for the answer, I'm glad I pirated the book lol Mar 13, 2018 at 17:59

The file type is normally determined with file. Its man states:

file — determine file type

But you can also to certain extent use type. Compare the two listings below for:

  • script.pl, a Perl script
  • not_a_script, an empty file

Here's one for the script:

$ ls
$ file script.pl 
script.pl: Perl script text executable
$ type script.pl
bash: type: script.pl: not found
$ type ./script.pl 
./script.pl is ./script.pl

And here's one for the empty file:

$ ls not_a_script 
$ file not_a_script 
not_a_script: empty
$ type not_a_script
bash: type: not_a_script: not found
$ type ./not_a_script
bash: type: ./not_a_script: not found

As you can see, type can determine if a file is executable. Is that a "determination of file type" or not? Well... In a different way to what file provides. The description of the type builtin in Bash's man is as follows:

type [-aftpP] name [name ...]

With no options, indicate how each name would be interpreted if used as a command name.

The correct answer to the question in the book should be in my opinion file, because that's what its man says, and that's what passing tests is about. Or in other words, my first choice is file.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .