Tools to Examine Linux Files

A dedicated server running Linux has an arsenal of file examination tools. Should you ever need to find out more information about a file or set of files, there are several commands that can help.

File – This simple command will give you more information about a file and help you determine what type of file it is.

$ file tiltshift2.png
tiltshift2.png: PNG image, 577 x 433, 8-bit/color RGB, non-interlaced

Cat – Typing “cat”, followed by the name of a file, will print its entire contents on the screen. For text files, such as HTML or PHP, you will see the code. For binary files, you will most likely see jumbled nonsense.

$ cat wp-rss.xml
<?xml version=”1.0″ encoding=”UTF-8″?>
<rss version=”2.0″…

More – If a file you print with Cat is particularly long, you can use More to paginate the file for viewing. Press the Space bar to move through the document one page at a time, or press Enter to move one line at a time.

Less – Like More, the main purpose of Less is to make it easier to view a long file. Less, however, will behave more like a real document viewer, allowing you to scroll up or down, page up or page down. To exit, you need to press “q”.

Grep – The mother of all file examination tools, the Grep command could take an entire book to explain adequately. Suffice it is to say, however, that it can find anything you want in a file.

$ grep nokia wp-rss.xml