Getting More Information About Filesystem Objects
Learn how to get information about filesystem objects.
We'll cover the following
We might be able to tell what type of file we’re working with by looking at its file name. Typically, a three or four-letter extension gives it away. For example, foo.pdf
is a PDF file, logo.png
is a graphics file, and foo.txt
is a plain text file. But sometimes there’s no extension, and sometimes the files are misnamed.
The file
command
The file
command can help us figure out what type of file we’re working with. Let’s try it out by pointing it at the greetings.txt
file we created in the root directory:
$ file greetings.txt
Run the complete code on the terminal below for practice.
echo > "Hello" > greetings.txt
file greetings.txt
Get hands-on with 1400+ tech skills courses.