it will show the type of the file
file file1
by using -b option ,output will only show the type of file omitting the file name
file -b file1
by using -b option ,output will only show the type of file omitting the file name
file -b file1
it will show mime type of files
file -i file1
if we have a compressed file we can see the uncompressed contents of a fiel
file -z compressed file name
file command can be used on multiple files
file file1 file2 file 3
it will display file type of all files
file *
want to display type of all files starting with m
file [m] *
displays type of all .txt files
file .txt*
Output:
example.txt: ASCII text
(This determines that example.txt is a text file.)
file example.txt
Output:
/home/user/: directory
(This confirms that /home/user/ is a directory.)
file /home/user/
Output:
/bin/ls: ELF 64-bit LSB executable, x86-64
(This confirms that /bin/ls is a 64-bit executable.)
file /bin/ls
Output:
archive.tar.gz: gzip compressed data
(This confirms that archive.tar.gz is a gzip-compressed file.)
file archive.tar.gz
Output:
picture.jpg: JPEG image data, JFIF standard
(This confirms that picture.jpg is a JPEG image.)
file picture.jpg
Output:
video.mp4: ISO Media, MP4 Base Media
(This determines that video.mp4 is an MP4 video.)
file video.mp4
Output:
file1.txt: ASCII text
file2.jpg: JPEG image data
file3.mp4: ISO Media, MP4 Base Media
(This determines the type of multiple files.)
file file1.txt file2.jpg file3.mp4
Output:
file1.txt: ASCII text
file2.jpg: JPEG image data
file3.mp4: ISO Media, MP4 Base Media
(This determines the type of multiple files.)
file file1.txt file2.jpg file3.mp4
Output:
document.pdf: application/pdf; charset=binary
(This displays the MIME type of the file.)
file -i document.pdf
Output:
document.pdf: application/pdf; charset=binary
(This displays the MIME type of the file.)
file -i document.pdf
Output:
/usr/bin/python3: symbolic link to /usr/bin/python3.8
(This reveals that /usr/bin/python3 is a symbolic link to another version.)
file -L /usr/bin/python3
If the file is corrupted, file may return:
corrupted_file: data
(This means that the file does not match any known type.)
file corrupted_file
Determines the type of a file.
file example.txt