Low Orbit Flux Logo 2 F

Linux Command - file

The linux file command will check and display the type of a file.

Use it to check file types:

file test1.txt
file test1.py
file /usr/bin/ls
file /lib64/ld-linux-x86-64.so.2

Try it on special files like this:

file /dev/sda
file /dev/sda1
file /proc/cpuinfo

Get more info from special files:

file -s /dev/sda
file -s /dev/sda1
file -s /proc/cpuinfo

Dereference links:

file -L link.txt

Show mime type string instead of human readable:

file test1.txt
file -i test1.txt

Uncompress, look inside compressed files:

file package.tar.gz
file -z package.tar.gz

Don’t change access time ( might not anyway ):

file -p test1.txt

-L dereference links
-i show mime type string instead of human readable
-p don’t change access time of file
-z uncompress, look inside compressed files
-s get more info from specail files

There are a lot of other options. Most of them aren’t really very common and are of limited use.