Understanding File Types in Unix: A Beginner's Guide

File types in unix operating system

In the Unix / Linux file system, there are three types of files:

ordinary files, directory files, and device files.

Ordinary files:

An ordinary file is a file that contains data, text, or binary information. This type of file is used to store data and is the most common type of file in a Linux system. Examples of ordinary files include text files, source code files, and image files. To view the contents of an ordinary file, you can use the 'cat' command.

Directory files:

A directory file, also known as a folder, is a special type of file that contains a list of other files and directories. The root directory of a Linux file system is represented by a forward slash (/) and contains all other files and directories in the system. To view the contents of a directory, you can use the 'ls' command.

Device files:

A device file is a special type of file that represents a device, such as a disk drive, keyboard, mouse, or printer.

Device files are located in the /dev directory and are used by the operating system to communicate with the device. Device files can be either character devices or block devices, depending on how the device transfers data.

For example, a disk drive is a block device, while a keyboard is a character device. To access a device file, you can use standard file I/O commands such as 'read' and 'write.'

Common File Types In Unix / Linux:

Linux / Unix uses a dot (.) to separate the filename from the file extension, which indicates the type of the file. Here are some common file types that you might encounter in a Unix system:

 

  1. .txt: Text files are plain text files that contain human-readable data. They can be opened and edited with any text editor, such as vi or nano.

     

  2. .pdf: PDF (Portable Document Format) files are a type of file that is used to present documents in a fixed layout, regardless of the software, hardware, or operating system used to create them. They can be opened with a PDF viewer, such as evince or Adobe Acrobat.

     

  3. .doc: Word document files are a type of file that is used to store text and formatting information for documents created with Microsoft Word. They can be opened with a word processor, such as LibreOffice Writer or Microsoft Word.

     

  4. .xls: Excel spreadsheet files are a type of file that is used to store data in a tabular format, with rows and columns. They can be opened with a spreadsheet application, such as LibreOffice Calc or Microsoft Excel.

     

  5. .png: PNG (Portable Network Graphics) files are a type of image file that is used to store bitmapped graphics. They are commonly used to store images that have a transparent background or that require high-quality resolution. They can be opened with an image viewer, such as gthumb or GIMP.

     

  6. .mp3: MP3 (MPEG Audio Layer 3) files are a type of audio file that is used to store digital audio data. They can be opened with a media player, such as VLC or iTunes.

     

By understanding these file types, you can better navigate and manage the files in your Unix system.

In
conclusion,
ordinary files, directory files, and device files are the
three types of files in the Unix / Linux file system.

Understanding the
differences between these file types is important for effective file
management and communication with the operating system and devices in a
Linux system.

Reference Books

Here are the books I’ve used as references for writing this article,
please feel free to read them If you don’t want your knowledge to be
limited to this article alone.