OnWorks Linux and Windows Online WorkStations

Logo

Free Hosting Online for WorkStations

< Previous | Contents | Next >

Determining A File's Type With file

As we explore the system it will be useful to know what files contain. To do this we will use the file command to determine a file's type. As we discussed earlier, filenames in Linux are not required to reflect a file's contents. While a filename like “picture.jpg” would normally be expected to contain a JPEG compressed image, it is not required to in Linux. We can invoke the file command this way:


file filename

file filename


When invoked, the file command will print a brief description of the file's contents. For example:



[me@linuxbox ~]$ file picture.jpg

picture.jpg: JPEG image data, JFIF standard 1.01

[me@linuxbox ~]$ file picture.jpg

picture.jpg: JPEG image data, JFIF standard 1.01


There are many kinds of files. In fact, one of the common ideas in Unix-like operating systems such as Linux is that “everything is a file.” As we proceed with our lessons, we will see just how true that statement is.

While many of the files on your system are familiar, for example MP3 and JPEG, there are many kinds that are a little less obvious and a few that are quite strange.


Top OS Cloud Computing at OnWorks: