Linux File Info Command

The Linux file command is a pretty basic command in Linux that will output the file type information onto your screen. There are quite a few options for the Linux file info command, but I only use maybe 2 of the options on a regular basis. With Microsoft Windows it will always think that the extension of he file determines the file type. If you have a file named filename.txt Windows will automatically think this file type is a text file, when it could actually be a pdf file with a bad extension on it! Now Linux on the other hand, if you come across a file that has a bad extension on it, you can run file filename.txt and it will output: filename.txt: PDF document, version 1.4 or whatever version of the pdf format it actually is.
The main options of the file command that I use is file -f [filename], where [filename] would be a standard text file with a list of files you want to have checked. If using this option you will want [filename] to have 1 filename per line.
The other option I use often isn’t really an option on the file command, but is a short script. You can run file `ls` and it will output the file types of all of the files that the ls command outputs normally, which will be all of the files listed in your current working directory.
I hope this Linux tutorial for beginners has helped you learn more about the Linux file type information command. As always if you have any questions or comments on this Linux tutorial you can leave them below, or you can use our Linux forum.

No comments:

Post a Comment