An ad-free and cookie-free website.
Learn to find a file's type at the Linux command line.
Videos can also be accessed from the Linux Essentials Playlist on YouTube.
Linux file Command Summary with Examples (3:54)
Our seventeenth word, or command to memorize is
file from the category Files.
file allows you to display a file's
||Print help screen|
||Input a list of files|
Recall from our video (tutorial) #11 we saw how the
type command showed
a command's type? Now we're interested in displaying a file's type,
meaning is it text, or a binary like an excutable, or an image file.
Before we start, it helps to think of commands as mini programs and
most follow this structure:
command -option(s) argument(s).
file command has
25 options and the argument is the file,
or list of files to test.
As with many commands, a double-dash
--help option is available.
The details here get complicated, so at this point, I'll just mention
-f option allows you to
input multiple filenames at once.
So why is
file an important command?
file helps you get organized,
and could help prevent you from running executables you know nothing
And now you know how to do that.
Okay, the best way to embed this in your memory is by typing in your own terminal window.
Find this on your Mac using a program called Terminal. On Linux use Terminal or Konsole, and currently Microsoft is adding this functionality to Windows.
Here we go, let's start by locating the
file command, with
There it is in
/usr/bin. So let's
file by typing
Replay that if it helps. Ok, we see it's an executable, and other technical details we shouldn't be concerned with right now.
Next, let's compare that output to the file from the previous
Empty. And then video11.txt?
That's an ASCII text file, very good.
And last, let's look at a configuration file like
.bashrc as well.
Text as well. Excellent.
Okay now you know how to use
And you know the syntax for commands, options and arguments.
One last tip about the
The user manual here, (
man file) while
advanced, does make for interesting reading. With coffee of course.
Okay, thanks for visiting today. I hope this was a fun introduction
For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:
The only way we can compete with the big corporations and offer better tutorials is with your support. Subscribe at YouTube, follow @factorpad and join our no-spam email list.
touchcommand, hit Back.
whichcommand, click Next.
A newly-updated free resource. Connect and refer a friend today.