Linux File Command
A record’s type is displayed the use of the Linux record instruction. It’s helpful on every occasion you want to determine what kind of record you’ve now not as soon as observed the rest like and even if the record has no extension. The record instruction is used to spot the record layout, similar to ASCII or MIME. It makes no difference between record extensions. The command’s sole function is to resolve the record kind. With the record instruction, you might make the most of various other parameters. Thus, inside of this information instructional, we will be able to be discussing the Linux record command the use of Ubuntu 20.04 device. Start this text via opening the Linux shell utility with “Ctrl+Alt+T”.
Simple File Command:
Let’s have a couple of illustrations of the use of Linux instructions with other choices. We will get started with making a easy textual content record with “touch” directions within the Linux shell. So, we will be able to be the use of the very elementary record command within the shell to test the present record kind, as proven within the connected screenshot symbol underneath. As the record is empty, it’s going to display that the record is now clean.
Now, we’ve added some content material within the record and displayed the content material of this record at the shell. For this function, we’ve applied the “cat” command. When we used the “file” command once more with the record identify, we’ve were given the record kind as “ASCII text”. If the record is of once more, it’s going to show that individual kind in your display.
This easy command can be used for the contents of an recognized location. So, we’ve attempted it with the “etc/group” location. It presentations that this folder incorporates an “ASCII” kind record.
The similar record command has been implemented to every other location. It presentations this folder incorporates handiest the “directory” kind and now not a unmarried record in it.
File Command with Steric (*) Character:
If a person needs to test the kind of a record or folder in a present location of Linux, he/she will use the record command with the “*” persona. This instruction will reveal the entire recordsdata and folders of a selected location, i.e., listing with their kind. Now, we’re these days held on the house listing of our Linux device. We have used the record command with the steric signal proven underneath. Upon the execution of this command, it presentations the entire recordsdata and folders of the house listing and their kind. Some recordsdata are “Html documents” having ASCII textual content kind. Some are easy textual content ASCII recordsdata. Some folders are easy directories however now not recordsdata.
Let’s take a look at how the “file” command with the “*” signal works at the specific folder. For that, we want to state the positioning of a folder. So, we’ve attempted it on our device’s “Documents” folder. You may have an concept of the Documents folder with the proven output. It presentations that the folder has handiest 3 recordsdata in it. One of the recordsdata is a “C” kind record having some ASCII textual content. One of them is the “Html” kind record with ASCII content material, and the 3rd is a straightforward textual content record, i.e., “ASCII text”.
File Command with “-b” Flag:
If you wish to have to simply see the kind of record, you’ll be able to use the “-b” flag throughout the “file” command within the shell. The command has been performed down within the symbol and presentations the record kind.
This “-b” flag within the “file” command can be used for the precise folder, i.e., Documents. You can take a look that it presentations handiest the kinds of recordsdata and now not the record names because it does within the “*” persona record command above. It merely presentations that there are handiest 3 recordsdata within the Documents folder having the desired kind.
File Command with “-i” Flag:
Another factor we will get from the record command is its MIME kind. The MIME kind approach to understand concerning the record’s extension and the kind of knowledge or content material it might retailer. This approach we will be able to be proven with the record extension on our output display. So, let’s use the record command with the “-I” flag with the precise record identify, i.e., “new.txt” within the shell. This record is these days positioned in the house folder. In go back, it displayed that the record “new.txt” incorporates a “text/plain” extension on its finish and must have some easy simple textual content knowledge in it. It additionally presentations the nature set of this actual record which is the “us-ASCII” kind.
Now, we’ve used this “-i” flag within the “file” command for the precise folder, i.e., Documents with “*” persona. In go back, it presentations the entire recordsdata these days held within the Documents folder with their extension kind identify and the content material kind, i.e., C-extension, html, or simple textual content
File Command with “-s” Flag:
The “-s” flag presentations the MIME form of a record extra in short and obviously. You can see the end result it presentations as extensions of recordsdata, i.e., C supply, Html record, and ASCII textual content.
File Command with Range:
You too can outline the variability of a record to be checked for a sort and show at the shell from a specified or present folder. The vary in alphabets, i.e., a to z, will probably be outlined throughout the sq. brackets. So, inside of our first representation, we’ve attempted to get the kind of a record having names ranging from alphabets “a” to “d”. It returns a unmarried consequence, as printed underneath.
Specifying the variability between “a” to “z” returns 3 of the entire effects.
Conclusion:
Finally, we’ve finished a easy representation of the use of the “file” command within the Ubuntu 20.04 Linux device. We have applied many flag choices in our representation to peer other views and usages of the “file” command of Linux. It presentations that the “file” command is reasonably flexible and multipurpose. With this, we extraordinarily consider that this article is going to turn out itself an excellent assist.