The Linux file command shows you the type of a file, or multiple files. It's usually used when you're about to look at some type of file you've never seen before. When I first started working with Unix and Linux systems I used it a lot to make sure I wasn't about to open a binary file in the vi editor, amongst other things.
You issue the Linux file command just like other commands, like this:
file /etc/passwd
The output of the file command looks something like this:
/etc/passwd: ASCII English text
This is telling you that this is a plain text file. If you use the file command on a gzip'd file, the output will include text like this:
gzip compressed data
If you issue this command on a directory the output will say "directory", a PDF document will be reported as "PDF document", and if you issue it on a special Linux device file (typically under the /dev directory) it will look like this:
/dev/ttyp0: character special (4/0)
You can also issue the Linux file command on more than one file at a time, so you can do this to issue the file command on all files in the current directory:
file *
or this to look at all files in the /etc directory:
file /etc/*
and like this to look at all files in the /dev directory:
file /dev/*
0 comments:
Post a Comment