{"id":15929,"date":"2022-01-27T09:43:59","date_gmt":"2022-01-27T09:43:59","guid":{"rendered":"https:\/\/www.hostinger.com\/tutorials\/?p=15929"},"modified":"2025-04-28T08:03:37","modified_gmt":"2025-04-28T08:03:37","slug":"linux-file-command","status":"publish","type":"post","link":"\/uk\/tutorials\/linux-file-command","title":{"rendered":"The Linux File Command: How to Use It to Determine a File Type"},"content":{"rendered":"<p>In UNIX-like systems, file names can be entirely different from their actual types. In some cases, they don&rsquo;t even have valid extensions. Therefore, it can make managing data more complicated.<\/p><p>To organize information quickly, Linux provides a program called the file command. It&rsquo;s primarily used to determine the file type &ndash; either American Standard Code for Information Interchange (ASCII) text or Multipurpose Internet Mail Extensions (MIME) format.<\/p><p>In this tutorial, you&rsquo;ll learn the basics of using the program and how it can empower your server management and Linux operation skills.<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/assets.hostinger.com\/content\/tutorials\/pdf\/Linux-Commands-Cheat-Sheet.pdf\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" width=\"1024\" height=\"283\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/11\/Linux-cheat-sheet-1024x283.png\" alt=\"\" class=\"wp-image-69262\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/11\/Linux-cheat-sheet-1536x425.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/11\/Linux-cheat-sheet-300x83.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/11\/Linux-cheat-sheet-150x41.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/11\/Linux-cheat-sheet-768x212.png 768w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/11\/Linux-cheat-sheet.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><p>\n\n\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-linux-file-command-syntax\">Linux File Command Syntax<\/h2><p>To use the Linux file command on a <a href=\"\/uk\/vps-hosting\">VPS hosting<\/a>, you&rsquo;ll have to connect it with an SSH client such as PuTTY or Terminal.<\/p><?xml encoding=\"utf-8\" ?><figure class=\"wp-block-image size-large\"><a href=\"\/uk\/vps-hosting\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" width=\"1024\" height=\"300\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner-1024x300.png\" alt=\"\" class=\"wp-image-77934\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/02\/VPS-hosting-banner.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/02\/VPS-hosting-banner-300x88.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/02\/VPS-hosting-banner-150x44.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/02\/VPS-hosting-banner-768x225.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><p>First, let&rsquo;s analyze the basic syntax of the file command:<\/p><p><strong>file [options] [file name]<\/strong><\/p><ul class=\"wp-block-list\">\n<li><strong>file<\/strong> &ndash; instructs the shell to execute the file command.<\/li>\n\n\n\n<li><strong>[options]<\/strong> &ndash; modifies the command&rsquo;s operation.<\/li>\n\n\n\n<li><strong>[file name]<\/strong> &ndash; inserts the file name you want to inspect.<\/li>\n<\/ul><p>When executed, the command doesn&rsquo;t consider its file extension. Instead, it runs three tests to determine the file type:<\/p><ul class=\"wp-block-list\">\n<li><strong>Filesystem test<\/strong> &ndash; examines the return from the stat system call. The program reviews if it is an empty file or a special file type. It also looks for known formats relevant to the system you work on if they&rsquo;re specified in the system header file.<\/li>\n\n\n\n<li><strong>Magic test<\/strong> &ndash; uses &ldquo;magic numbers,&rdquo; a short string of numbers at the beginning of a file, to check whether it is binary executable data. The necessary information to run this test is available in <strong>\/etc\/magic<\/strong> or <strong>\/usr\/share\/misc\/magic<\/strong> from a compiled magic file.<\/li>\n\n\n\n<li><strong>Language test<\/strong> &ndash; examines the character sets the file is written in, such as ASCII text or UTF-8. It looks for any special sequence that appears in the first few lines. This test is less accurate, so it&rsquo;s performed last.<\/li>\n<\/ul><p>The command&rsquo;s output displays the file type using the standard format. Depending on the command option, it may provide other information, such as data stored in compressed files, size, or version.<\/p><p>The <strong>option <\/strong>in the syntax allows you to add variables to the Linux file command. Here are some common examples:<\/p><ul class=\"wp-block-list\">\n<li><strong>-b<\/strong> or <strong>&ndash;brief<\/strong> &ndash; fetches a short description of the file type.<\/li>\n\n\n\n<li><strong>file *<\/strong> &ndash; lists all file types in the current working directory.<\/li>\n\n\n\n<li><strong>-i<\/strong> or<strong> &ndash;mime<\/strong> &ndash; shows the MIME file type.<\/li>\n\n\n\n<li><strong>-s<\/strong> or <strong>&ndash;special-files<\/strong> &ndash; reads special files.<\/li>\n\n\n\n<li><strong>-z<\/strong> or <strong>&ndash;uncompress &ndash; <\/strong>checks and displays information inside compressed files.<\/li>\n\n\n\n<li><strong>-c or &ndash;checking-printout &ndash; <\/strong>checks a magic file&rsquo;s parsed version.<\/li>\n\n\n\n<li><strong>-m<\/strong> or <strong>&ndash;magic-file<\/strong> &ndash; utilizes an alternative magic file provided by the user.<\/li>\n\n\n\n<li><strong>-d<\/strong> &ndash; displays internal debugging information using the standard format.<\/li>\n\n\n\n<li><strong>&lt;regex range&gt;<\/strong> &ndash; fetches file types in specific ranges.<\/li>\n\n\n\n<li><strong>-0<\/strong> or <strong>&ndash;print0<\/strong> &ndash; prints a null character at the end of the file name.<\/li>\n\n\n\n<li><strong>&ndash;help<\/strong> &ndash; shows the file command&rsquo;s help message. It also lists acceptable options and their usage.<\/li>\n<\/ul><p>Before we talk about each option separately, use the nano editor to create a sample text named <strong>test.txt<\/strong>:<\/p><p><strong>nano test.txt<\/strong><\/p><p>Once the command line opens a new file, write a few lines of text and press <strong>Ctrl + X<\/strong> and <strong>Y <\/strong>to exit and save your changes.<\/p><p>\n\n\n<div class=\"protip\">\n                    <h4 class=\"title\">Suggested Reading<\/h4>\n                    <p><a href=\"\/uk\/tutorials\/linux-commands\">40 Essential Linux Commands That Every User Should Know<\/a><\/p>\n                <\/div>\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-linux-file-command-examples\">Linux File Command Examples<\/h2><p>In the following sections, we&rsquo;ll discuss how to use each of the options listed previously.<\/p><h3 class=\"wp-block-heading\" id=\"h-use-file-to-check-the-file-type\">Use File to Check the File Type<\/h3><p>In Linux, while users can rename their files, the updated information may not represent the actual data. To find the correct type of a file, enter:<\/p><p><strong>file filename<\/strong><\/p><p>For example, you rename <strong>test.txt<\/strong> to <strong>text.zip<\/strong>. To reveal the valid file type, enter:<\/p><p><strong>file text.zip<\/strong><\/p><p>The output will display the name and its actual type, an ASCII text file:<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/01\/The-Linux-file-command-on-Terminal-displaying-the-correct-file-type.png\"><img decoding=\"async\" width=\"240\" height=\"34\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/01\/The-Linux-file-command-on-Terminal-displaying-the-correct-file-type.png\" alt=\"The Linux file command on Terminal, displaying the correct file type\" class=\"wp-image-67161\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/01\/The-Linux-file-command-on-Terminal-displaying-the-correct-file-type.png 240w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/01\/The-Linux-file-command-on-Terminal-displaying-the-correct-file-type-150x21.png 150w\" sizes=\"(max-width: 240px) 100vw, 240px\" \/><\/a><\/figure><\/div><p>To view the format in brief mode, use the <strong>-b<\/strong> option on Terminal, followed by the file name. For example:<\/p><p><strong>file -b text.zip<\/strong><\/p><p>The output will show the file type<strong> <\/strong>without its name:<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/01\/Check-a-file-type-using-the-brief-mode-on-Terminal.png\"><img decoding=\"async\" width=\"247\" height=\"32\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/01\/Check-a-file-type-using-the-brief-mode-on-Terminal.png\" alt=\"Check a file type using the brief mode on Terminal\" class=\"wp-image-67162\" style=\"width:247px;height:32px\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/01\/Check-a-file-type-using-the-brief-mode-on-Terminal.png 247w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/01\/Check-a-file-type-using-the-brief-mode-on-Terminal-150x19.png 150w\" sizes=\"(max-width: 247px) 100vw, 247px\" \/><\/a><\/figure><\/div><h3 class=\"wp-block-heading\" id=\"h-use-file-to-list-the-file-type-of-multiple-files\">Use File to List the File Type of Multiple Files<\/h3><p>The file command can list each file type in the home directory. To do this, enter <strong>file<\/strong> and add a wildcard character (<strong>*<\/strong>):<\/p><p><strong>file *<\/strong><\/p><p>The program will show all the files and directories:<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/01\/List-file-types-in-a-directory-using-the-Linux-file-command-on-Terminal.png\"><img decoding=\"async\" width=\"195\" height=\"66\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/01\/List-file-types-in-a-directory-using-the-Linux-file-command-on-Terminal.png\" alt=\"List file types in a directory using the Linux file command on Terminal\" class=\"wp-image-67163\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/01\/List-file-types-in-a-directory-using-the-Linux-file-command-on-Terminal.png 195w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/01\/List-file-types-in-a-directory-using-the-Linux-file-command-on-Terminal-150x51.png 150w\" sizes=\"(max-width: 195px) 100vw, 195px\" \/><\/a><\/figure><\/div><p>In addition, the file command can show each file type inside a specific directory. Here&rsquo;s the general syntax:<\/p><p><strong>file [path-to-directory]\/*<\/strong><\/p><h3 class=\"wp-block-heading\" id=\"h-use-file-to-find-the-mime-file-type\">Use File to Find the MIME File Type<\/h3><p>The<strong> -i<\/strong> option is used to view the <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTTP\/Basics_of_HTTP\/MIME_types\" target=\"_blank\" rel=\"noreferrer noopener\">MIME file type<\/a>. It consists of two parts &ndash; a type and a subtype. MIME uses a slash (\/) to separate each of them, with no space in between.<\/p><p>Here&rsquo;s the general syntax:<\/p><p><strong>file -i filename<\/strong><\/p><p>For example, to view the MIME type of the <strong>test2.txt<\/strong> file, enter:<\/p><p><strong>file -i test2.txt<\/strong><\/p><p>Here&rsquo;s the output of the file command above:<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/01\/View-the-MIME-type-of-a-file-using-the-Linux-file-command-on-Terminal.png\"><img decoding=\"async\" width=\"303\" height=\"34\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/01\/View-the-MIME-type-of-a-file-using-the-Linux-file-command-on-Terminal.png\" alt=\"View the MIME type of a file using the Linux file command on Terminal\" class=\"wp-image-67164\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/01\/View-the-MIME-type-of-a-file-using-the-Linux-file-command-on-Terminal.png 303w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/01\/View-the-MIME-type-of-a-file-using-the-Linux-file-command-on-Terminal-300x34.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/01\/View-the-MIME-type-of-a-file-using-the-Linux-file-command-on-Terminal-150x17.png 150w\" sizes=\"(max-width: 303px) 100vw, 303px\" \/><\/a><\/figure><\/div><p>Instead of declaring the file format as ASCII text, the program defines the file as <strong>text\/plain <\/strong>and <strong>charset=us-ascii<\/strong>.<\/p><h3 class=\"wp-block-heading\" id=\"h-use-file-to-read-the-special-file-type\">Use File to Read the Special File Type<\/h3><p>The file command allows you to read special files, such as system information, by adding the <strong>-s<\/strong> option.<\/p><p>\n\n\n<div><p class=\"important\"><strong>Important!<\/strong> Keep in mind that only a root user can run the file command along the -s option. Otherwise, you&rsquo;ll receive a no-read permission error message.<\/p><\/div>\n\n\n\n<\/p><p>This option only classifies a file as a block special file, symbolic link, directory, or nonexistent.<\/p><p>Here&rsquo;s its general format:<\/p><p><strong>sudo file -s filename<\/strong><\/p><p>For example, to read the <strong>ploop19269<\/strong> file, enter:<\/p><p><strong>sudo file -s \/dev\/ploop19269<\/strong><\/p><p>The output indicates that <strong>ploop19269 <\/strong>is a DOS\/MBR boot sector.<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/01\/Read-a-block-special-file-using-the-Linux-file-command-on-Terminal.png\"><img decoding=\"async\" width=\"975\" height=\"90\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/01\/Read-a-block-special-file-using-the-Linux-file-command-on-Terminal.png\" alt=\"Read a block special file using the Linux file command on Terminal\" class=\"wp-image-67165\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/01\/Read-a-block-special-file-using-the-Linux-file-command-on-Terminal.png 975w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/01\/Read-a-block-special-file-using-the-Linux-file-command-on-Terminal-300x28.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/01\/Read-a-block-special-file-using-the-Linux-file-command-on-Terminal-150x14.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/01\/Read-a-block-special-file-using-the-Linux-file-command-on-Terminal-768x71.png 768w\" sizes=\"(max-width: 975px) 100vw, 975px\" \/><\/a><\/figure><\/div><h3 class=\"wp-block-heading\" id=\"h-use-file-to-read-a-compressed-file\">Use File to Read a Compressed File<\/h3><p>There are two ways to check compressed files like <strong>ZIP <\/strong>or <strong>gzip <\/strong>archives, the <strong>-z<\/strong> and <strong>-Z<\/strong> options. The former displays detailed information and its content, while the latter only shows the file types.<\/p><p>Here&rsquo;s the general syntax of the <strong>-z <\/strong>option:<\/p><p><strong>file -z filename<\/strong><\/p><p>For example, to read the <strong>test2.txt.gz<\/strong> file&rsquo;s complete data, enter:<\/p><p><strong>file -z test2.txt.gz<\/strong><\/p><p>The output specifies that <strong>test2.txt.gz <\/strong>is a <a href=\"\/uk\/tutorials\/enable-gzip-compression\"><strong>gzip<\/strong> compressed<\/a> file that contains <strong>test2.txt<\/strong>:<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/01\/Check-a-compressed-file-using-the-Linux-file-command-on-Terminal.png\"><img decoding=\"async\" width=\"777\" height=\"52\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/01\/Check-a-compressed-file-using-the-Linux-file-command-on-Terminal.png\" alt=\"Check a compressed file using the Linux file command on Terminal\" class=\"wp-image-67166\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/01\/Check-a-compressed-file-using-the-Linux-file-command-on-Terminal.png 777w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/01\/Check-a-compressed-file-using-the-Linux-file-command-on-Terminal-300x20.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/01\/Check-a-compressed-file-using-the-Linux-file-command-on-Terminal-150x10.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/01\/Check-a-compressed-file-using-the-Linux-file-command-on-Terminal-768x51.png 768w\" sizes=\"(max-width: 777px) 100vw, 777px\" \/><\/a><\/figure><\/div><p>Here&rsquo;s the general format of the <strong>-Z <\/strong>option:<\/p><p><strong>file -Z filename<\/strong><\/p><p>For example, to view the file type of <strong>test.gz <\/strong>only, enter:<\/p><p><strong>file -Z test.gz<\/strong><\/p><p>This command will only print out the type of the file inside <strong>test.gz <\/strong>&ndash; an ASCII text.<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/01\/View-the-type-of-a-file-using-the-Linux-file-command-on-Terminal.png\"><img decoding=\"async\" width=\"303\" height=\"33\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/01\/View-the-type-of-a-file-using-the-Linux-file-command-on-Terminal.png\" alt=\"View the type of a file using the Linux file command on Terminal\" class=\"wp-image-67167\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/01\/View-the-type-of-a-file-using-the-Linux-file-command-on-Terminal.png 303w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/01\/View-the-type-of-a-file-using-the-Linux-file-command-on-Terminal-300x33.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/01\/View-the-type-of-a-file-using-the-Linux-file-command-on-Terminal-150x16.png 150w\" sizes=\"(max-width: 303px) 100vw, 303px\" \/><\/a><\/figure><\/div><h3 class=\"wp-block-heading\" id=\"h-use-file-to-test-parsed-version-of-a-file\">Use File to Test Parsed Version of a File<\/h3><p>Adding the<strong> -c<\/strong> option allows you to view the parsed version of any file. It shows information such as type, opcode, and value. Usually, it is used in conjugation with the <strong>-m<\/strong> option to debug a new magic file before installing it.<\/p><p>Here&rsquo;s its general syntax:<\/p><p><strong>file -c filename<\/strong><\/p><p>For example, to print the parsed form of the <strong>test.txt<\/strong> file, enter:<\/p><p><strong>file -c test.txt<\/strong><\/p><p>The output should look like this:<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/01\/Printing-the-parsed-form-of-a-file-using-the-Linux-file-command-on-Terminal.png\"><img decoding=\"async\" width=\"380\" height=\"35\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/01\/Printing-the-parsed-form-of-a-file-using-the-Linux-file-command-on-Terminal.png\" alt=\"Printing the parsed form of a file using the Linux file command on Terminal\" class=\"wp-image-67168\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/01\/Printing-the-parsed-form-of-a-file-using-the-Linux-file-command-on-Terminal.png 380w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/01\/Printing-the-parsed-form-of-a-file-using-the-Linux-file-command-on-Terminal-300x28.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/01\/Printing-the-parsed-form-of-a-file-using-the-Linux-file-command-on-Terminal-150x14.png 150w\" sizes=\"(max-width: 380px) 100vw, 380px\" \/><\/a><\/figure><\/div><h3 class=\"wp-block-heading\" id=\"h-use-file-to-list-file-types\">Use File to List File Types<\/h3><p>The file command lists all file types in a directory using the Regex-style ranges. Type <strong>file <\/strong>and place the values in brackets, followed by <strong>*<\/strong>.<\/p><p>Its general syntax is:<\/p><p><strong>file [range1-range2]*<\/strong><\/p><p>For example, to examine files starting within the <strong>a <\/strong>to <strong>z<\/strong> range, enter:<\/p><p><strong>file [a-z]*<\/strong><\/p><p>The output should look like this:<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/01\/List-file-types-within-a-range-using-the-Linux-file-command-on-Terminal.png\"><img decoding=\"async\" width=\"773\" height=\"99\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/01\/List-file-types-within-a-range-using-the-Linux-file-command-on-Terminal.png\" alt=\"List file types within a range using the Linux file command on Terminal\" class=\"wp-image-67169\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/01\/List-file-types-within-a-range-using-the-Linux-file-command-on-Terminal.png 773w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/01\/List-file-types-within-a-range-using-the-Linux-file-command-on-Terminal-300x38.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/01\/List-file-types-within-a-range-using-the-Linux-file-command-on-Terminal-150x19.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/01\/List-file-types-within-a-range-using-the-Linux-file-command-on-Terminal-768x98.png 768w\" sizes=\"(max-width: 773px) 100vw, 773px\" \/><\/a><\/figure><\/div><p>Since this program is case-sensitive, the output will only show the files starting with a lowercase a to z. To include the uppercase characters, add another range. For example:<\/p><p><strong>file [a-z]* [A-Z]*<\/strong><\/p><p>Here&rsquo;s what the output looks like:<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/01\/List-file-types-within-multiple-ranges-using-the-Linux-file-command-on-Terminal.png\"><img decoding=\"async\" width=\"782\" height=\"148\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/01\/List-file-types-within-multiple-ranges-using-the-Linux-file-command-on-Terminal.png\" alt=\"List file types within multiple ranges using the Linux file command on Terminal\" class=\"wp-image-67170\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/01\/List-file-types-within-multiple-ranges-using-the-Linux-file-command-on-Terminal.png 782w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/01\/List-file-types-within-multiple-ranges-using-the-Linux-file-command-on-Terminal-300x57.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/01\/List-file-types-within-multiple-ranges-using-the-Linux-file-command-on-Terminal-150x28.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/01\/List-file-types-within-multiple-ranges-using-the-Linux-file-command-on-Terminal-768x145.png 768w\" sizes=\"(max-width: 782px) 100vw, 782px\" \/><\/a><\/figure><\/div><h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2><p>In UNIX systems, file names and extensions can differ from their actual types. Hence, Linux provides the file command to help users determine the type of a file.<\/p><p>When executing it, use appropriate options and specify the file name. There are many acceptable variables to use with the file command, such as:<\/p><ul class=\"wp-block-list\">\n<li><strong>-c<\/strong> &ndash; tests the parsed form of a file.<\/li>\n\n\n\n<li><strong>-i <\/strong>&ndash; finds the mime type.<\/li>\n\n\n\n<li><strong>*<\/strong> &ndash; lists multiple files.<\/li>\n\n\n\n<li><strong>-z<\/strong> &ndash; reads compressed content.<\/li>\n<\/ul><p>We hope this article has helped you learn how to manage data using the Linux file command. If you have any questions or suggestions, please leave them in the comments section below.<\/p><p>\n\n\n<div class=\"protip\">\n                    <h4 class=\"title\">Learn More Linux Commands for File Management<\/h4>\n                    <p><a href=\"\/uk\/tutorials\/how-to-remove-files-and-folders-using-linux-command-line\/\">Remove Directory in Linux: How to Delete Files and Folders<\/a><br>\n<a href=\"\/uk\/tutorials\/how-to-use-find-and-locate-commands-in-linux\/\">How to Use the Linux Locate Command to Find Any File<\/a><br>\n<a href=\"\/uk\/tutorials\/linux-tee-command-with-examples\/\">Using Tee Command to Write to Files<\/a><br>\n<a href=\"\/uk\/tutorials\/linux-tar-command-with-examples\/\">How to Use the Tar Command in Linux<\/a><br>\n<a href=\"\/uk\/tutorials\/how-to-rename-files-in-linux\/\">How to Rename a File<\/a><br>\n<a href=\"\/uk\/tutorials\/how-to-create-symbolic-links-in-linux\/\">How to Create Linux Symlinks (Symbolic Links) for Files and Directories<\/a><br>\n<a href=\"\/uk\/tutorials\/how-to-install-and-use-linux-screen\/\">How to Install and Use Linux Screen<\/a><br>\n<a href=\"\/uk\/tutorials\/how-to-use-rsync\/\">How to Use rsync Command to Transfer and Sync Files<\/a><br>\n<a href=\"\/uk\/tutorials\/how-to-use-linux-sed-command-examples\/\">How to Read a File With Sed Command<\/a><br>\n<a href=\"\/uk\/tutorials\/how-to-unzip-files-linux\/\">How to Unzip Files in Linux<\/a><br>\n<a href=\"\/uk\/tutorials\/using-scp-command-to-transfer-files\/\">How to Use SCP Command to Copy and Transfer Files in Linux<\/a><\/p>\n                <\/div>\n\n\n\n<\/p><h3 class=\"wp-block-heading\" id=\"h-linux-file-command-faq\">Linux File Command FAQ<\/h3><p>In this section, we will answer the most common questions about the Linux file command.<\/p><div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1666861662468\"><h3 class=\"schema-faq-question\">What Exactly Does the Linux File Command Do?<\/h3> <p class=\"schema-faq-answer\">File names in UNIX can be entirely independent of the file types. Thus, it&rsquo;s tricky to determine the actual information.&nbsp;<br><br>Executing the file command reveals what format a file uses and examines each <a href=\"https:\/\/www.javatpoint.com\/linux-arguments\" target=\"_blank\" rel=\"noreferrer noopener\">argument<\/a> by conducting three tests &ndash; filesystem, magic, and language tests. The first that succeeds will output the file type.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1666861677521\"><h3 class=\"schema-faq-question\">Which Linux Command Creates a Blank File in the Current Directory?<\/h3> <p class=\"schema-faq-answer\">To create one or multiple empty files, use the <a href=\"\/uk\/tutorials\/linux-touch-command-with-useful-examples\/\">touch command<\/a>. It comes with the Linux system and is especially useful when you don&rsquo;t have data to store at the time.<br><br>Its general syntax is: <strong>touch filename<\/strong>. To create multiple files, enter: <strong>touch filename1 filename2<\/strong>.<\/p> <\/div> <\/div>\n","protected":false},"excerpt":{"rendered":"<p>In UNIX-like systems, file names can be entirely different from their actual types. In some cases, they don&rsquo;t even have valid extensions. Therefore, it can make managing data more complicated. To organize information quickly, Linux provides a program called the file command. It&rsquo;s primarily used to determine the file type &ndash; either American Standard Code [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/uk\/tutorials\/linux-file-command\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":110,"featured_media":24090,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"What Is Linux File Command and How To Determine File Type","rank_math_description":"Linux file command helps determine the file type and its contents. Learn more about file commands and deepen your VPS knowledge in this article.","rank_math_focus_keyword":"file command","footnotes":""},"categories":[22644,22640],"tags":[],"class_list":["post-15929","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-managing-monitoring-and-security","category-vps"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/linux-file-command","default":0},{"locale":"fr-FR","link":"https:\/\/www.hostinger.com\/fr\/tutoriels\/commande-file-linux","default":0},{"locale":"en-UK","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/linux-file-command","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/how-to-use-the-linux-file-command","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/how-to-use-the-linux-file-command","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/linux-file-command","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/linux-file-command","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/linux-file-command","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/linux-file-command","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/posts\/15929","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/users\/110"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/comments?post=15929"}],"version-history":[{"count":31,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/posts\/15929\/revisions"}],"predecessor-version":[{"id":127557,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/posts\/15929\/revisions\/127557"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/media\/24090"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/media?parent=15929"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/categories?post=15929"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/tags?post=15929"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}