HomeLinuxAll the pieces Is a File and Forms of Information in Linux

All the pieces Is a File and Forms of Information in Linux


If you’re new to Linux or have used it for a couple of months, then you should have heard or learn statements akin to “In Linux, the whole lot is a File”.

That’s actually true though it’s only a generalization idea, in Unix and its derivatives akin to Linux, the whole lot is taken into account as a file. If one thing shouldn’t be a file, then it have to be working as a course of on the system.

To know this, take for instance the quantity of area in your root (/) listing is all the time consumed by various kinds of Linux information. While you create a file or switch a file to your system, it occupies some area on the bodily disk and it’s thought-about to be in a particular format (file kind).

Everything is a File and Types of Files in Linux
All the pieces is a File and Forms of Information in Linux

Additionally, the Linux system doesn’t differentiate between information and directories, however directories do one essential job, which is to retailer different information in teams in a hierarchy for straightforward location. All of your {hardware} parts are represented as information and the system communicates with them utilizing these information.

The thought is a vital description of an excellent property of Linux, the place enter/output sources akin to your paperwork, directories (folders in Mac OS X and Home windows), keyboard, monitor, arduous drives, detachable media, printers, modems, digital terminals, and in addition inter-process and community communication are streams of bytes outlined by file system area.

A notable benefit of the whole lot being a file is that the identical set of Linux instruments, utilities, and APIs can be utilized on the above enter/output sources. Though the whole lot in Linux is a file, there are particular particular information which might be greater than only a file for instance sockets and named pipes.

Completely different Forms of Information in Linux?

In Linux there are mainly three kinds of information:

  1. Unusual/Common information
  2. Particular information
  3. Directories

Unusual/Common Information

These are information knowledge include textual content, knowledge, or program directions and they’re the commonest kind of information you’ll be able to anticipate finding on a Linux system they embody:

  1. Readable information
  2. Binary information
  3. Picture information
  4. Compressed information and so forth.

Particular Information

Particular information embody the next:

Linux Block Information

These are gadget information that present buffered entry to system {hardware} parts. They supply a way of communication with gadget drivers by means of the file system.

One essential side of block information is that they will switch a big block of information and knowledge at a given time.

Itemizing block information sockets in a listing utilizing the ls command:

# ls -l /dev | grep "^b"

brw-rw----  root disk        0 B  Wed Apr 26 08:39:09 2023 loop0
brw-rw----  root disk        0 B  Wed Apr 26 08:39:09 2023 loop1
brw-rw----  root disk        0 B  Wed Apr 26 08:39:09 2023 loop2
brw-rw----  root disk        0 B  Wed Apr 26 08:39:09 2023 loop3
brw-rw----  root disk        0 B  Wed Apr 26 08:39:09 2023 loop4
brw-rw----  root disk        0 B  Wed Apr 26 08:39:09 2023 loop5
brw-rw----  root disk        0 B  Wed Apr 26 08:39:09 2023 loop6
brw-rw----  root disk        0 B  Wed Apr 26 08:39:09 2023 loop7
brw-rw----  root disk        0 B  Wed Apr 26 08:39:09 2023 sda
brw-rw----  root disk        0 B  Wed Apr 26 08:39:09 2023 sda1
brw-rw----  root disk        0 B  Wed Apr 26 08:39:10 2023 sda2
brw-rw----  root disk        0 B  Wed Apr 26 08:39:09 2023 sdb
brw-rw----  root disk        0 B  Wed Apr 26 08:39:09 2023 sdb1
brw-rw----  root disk        0 B  Wed Apr 26 08:39:09 2023 sdb2
brw-rw----  root disk        0 B  Wed Apr 26 08:39:09 2023 sdb3
...
Linux Character Information

These are additionally gadget information that present unbuffered serial entry to system {hardware} parts. They work by offering a manner of communication with units by transferring knowledge one character at a time.

Itemizing character information sockets in a listing:

# ls -l /dev | grep "^c"

crw-r--r--  root root        0 B  Wed Apr 26 08:39:09 2023 autofs
crw-rw----  root disk        0 B  Wed Apr 26 08:39:09 2023 btrfs-control
crw--w----  root tty         0 B  Wed Apr 26 08:39:09 2023 console
crw-------  root root        0 B  Wed Apr 26 08:39:09 2023 cpu_dma_latency
crw-------  root root        0 B  Wed Apr 26 08:39:09 2023 cuse
crw-------  root root        0 B  Wed Apr 26 08:39:09 2023 ecryptfs
crw-rw----  root video       0 B  Wed Apr 26 08:39:09 2023 fb0
crw-rw-rw-  root root        0 B  Wed Apr 26 08:39:09 2023 full
crw-rw-rw-  root root        0 B  Wed Apr 26 08:39:09 2023 fuse
crw-------  root root        0 B  Wed Apr 26 08:39:09 2023 hidraw0
crw-------  root root        0 B  Wed Apr 26 08:39:09 2023 hidraw1
crw-------  root root        0 B  Wed Apr 26 08:39:09 2023 hidraw2
crw-------  root root        0 B  Wed Apr 26 08:39:09 2023 hidraw3
crw-------  root root        0 B  Wed Apr 26 08:39:09 2023 hpet
crw-------  root root        0 B  Wed Apr 26 08:39:09 2023 hwrng
crw-------  root root        0 B  Wed Apr 26 08:39:09 2023 i2c-0
crw-------  root root        0 B  Wed Apr 26 08:39:12 2023 i2c-1
crw-------  root root        0 B  Wed Apr 26 08:39:12 2023 i2c-2
crw-------  root root        0 B  Wed Apr 26 08:39:12 2023 i2c-3
crw-r--r--  root root        0 B  Wed Apr 26 08:39:09 2023 kmsg
crw-rw----+ root kvm         0 B  Wed Apr 26 08:39:09 2023 kvm
crw-rw----  root disk        0 B  Wed Apr 26 08:39:09 2023 loop-control
crw-rw----  root lp          0 B  Wed Apr 26 08:39:09 2023 lp0
crw-------  root root        0 B  Wed Apr 26 08:39:09 2023 mcelog
crw-------  root root        0 B  Wed Apr 26 08:39:09 2023 mei0
...
Linux Symbolic Hyperlink Information

A symbolic hyperlink is a reference to a different file on the system. Due to this fact, symbolic hyperlink information are information that time to different information, they usually can both be directories or common information.

Itemizing symbolic hyperlink sockets in a listing:

# ls -l /dev/ | grep "^l"

lrwxrwxrwx  root root       13 B  Wed Apr 26 08:39:04 2023 fd ⇒ /proc/self/fd
lrwxrwxrwx  root root       11 B  Wed Apr 26 08:39:04 2023 core ⇒ /proc/kcore
lrwxrwxrwx  root root       12 B  Wed Apr 26 08:39:09 2023 initctl ⇒ /run/initctl
lrwxrwxrwx  root root       28 B  Wed Apr 26 08:39:09 2023 log ⇒ /run/systemd/journal/dev-log
lrwxrwxrwx  root root        4 B  Wed Apr 26 08:39:09 2023 rtc ⇒ rtc0
lrwxrwxrwx  root root       15 B  Wed Apr 26 08:39:04 2023 stderr ⇒ /proc/self/fd/2
lrwxrwxrwx  root root       15 B  Wed Apr 26 08:39:04 2023 stdin ⇒ /proc/self/fd/0
lrwxrwxrwx  root root       15 B  Wed Apr 26 08:39:04 2023 stdout ⇒ /proc/self/fd/1
...

You may make symbolic hyperlinks utilizing the ln utility in Linux as within the instance under.

# contact file1.txt
# ln -s file1.txt /house/tecmint/file1.txt  [create symbolic link]
# ls -l /house/tecmint/ | grep "^l"         [List symbolic links]

Within the above instance, I created a file referred to as file1.txt in /tmp listing, then created the symbolic hyperlink, /house/tecmint/file1.txt to level to /tmp/file1.txt.

Linux Pipes or Named Pipes

These are information that enable inter-process communication by connecting the output of 1 course of to the enter of one other. A named pipe is definitely a file that’s utilized by two processes to speak with every and it acts as a Linux pipe.

Itemizing pipes sockets in a listing:

# ls -l | grep "^p"

prw-rw-r-- 1 tecmint tecmint    0 Apr 18 17:47 pipe1
prw-rw-r-- 1 tecmint tecmint    0 Apr 18 17:47 pipe2
prw-rw-r-- 1 tecmint tecmint    0 Apr 18 17:47 pipe3
prw-rw-r-- 1 tecmint tecmint    0 Apr 18 17:47 pipe4
prw-rw-r-- 1 tecmint tecmint    0 Apr 18 17:47 pipe5

You should utilize the mkfifo utility to create a named pipe in Linux as follows.

# mkfifo pipe1
# echo "That is named pipe1" > pipe1

Within the above instance, I created a named pipe referred to as pipe1, then I handed some knowledge to it utilizing the echo command, after that the shell grew to become un-interactive whereas processing the enter.

Then I opened one other shell and run one other command to print out what was handed to the pipe.

# whereas learn line ;do echo "This was passed-'$line' "; finished<pipe1
Linux Socket Information

These are information that present a method of inter-process communication, however they will switch knowledge and knowledge between processes working on completely different environments.

Because of this sockets present knowledge and knowledge switch between processes working on completely different machines on a community.

An instance to point out the work of sockets could be an internet browser making a connection to an internet server.

# ls -l /dev/ | grep "^s"

srw-rw-rw-  1 root root             0 Apr 18 10:26 log

That is an instance of a socket created in C through the use of the socket() system name.

int socket_desc= socket(AF_INET, SOCK_STREAM, 0 );

Within the above:

  • AF_INET is the handle household(IPv4)
  • SOCK_STREAM is the sort (connection is TCP protocol oriented)
  • 0 is the protocol(IP Protocol)

To check with the socket file, use the socket_desc, which is identical because the file descriptor, and use learn() and write() system calls to learn and write from the socket respectively.

Linux Particular Directories

These are particular information that retailer each abnormal and different particular information and they’re organized on the Linux file system in a hierarchy ranging from the basis (/) listing.

Itemizing sockets in a listing:

# ls -l / | grep "^d"

drwxr-xr-x root root 4.0 KB Fri Apr 21 10:21:42 2023 boot
drwxr-xr-x root root 4.0 KB Wed Oct  6 22:55:05 2021 cdrom
drwxr-xr-x root root 4.4 KB Wed Apr 26 08:39:12 2023 dev
drwxr-xr-x root root  12 KB Sat Apr 22 10:59:02 2023 and many others
drwxr-xr-x root root 4.0 KB Wed Oct  6 22:55:12 2021 house
drwx------ root root  16 KB Wed Oct  6 22:52:31 2021 misplaced+discovered
drwxr-xr-x root root 4.0 KB Thu Oct  7 18:03:09 2021 media
drwxr-xr-x root root 4.0 KB Mon Jul 18 11:34:54 2022 mnt
drwxr-xr-x root root 4.0 KB Tue Apr  4 15:09:01 2023 choose
dr-xr-xr-x root root   0 B  Wed Apr 26 08:39:04 2023 proc
drwx------ root root 4.0 KB Fri Apr  7 11:28:42 2023 root
drwxr-xr-x root root 1.1 KB Wed Apr 26 08:44:09 2023 run
drwxr-xr-x root root 4.0 KB Wed Dec 15 13:23:40 2021 srv
dr-xr-xr-x root root   0 B  Wed Apr 26 08:39:04 2023 sys
drwxrwxrwt root root 4.0 KB Wed Apr 26 10:14:23 2023 tmp
drwxr-xr-x root root 4.0 KB Sat Jul  3 22:29:26 2021 usr
drwxr-xr-x root root 4.0 KB Thu Mar 30 10:46:04 2023 var

You may make a listing utilizing the mkdir command.

# mkdir -m 1666 tecmint.com
# mkdir -m 1666 information.tecmint.com
# mkdir -m 1775 linuxsay.com
Abstract

It’s best to now be having a transparent understanding of why the whole lot in Linux is a file and the various kinds of information that may exist in your Linux system.

You may add extra to this by studying extra concerning the particular person file sorts and they’re created. I hope you discover this information useful and for any questions and extra data that you’d like to share, please depart a remark and we will talk about extra.

If You Recognize What We Do Right here On TecMint, You Ought to Think about:

TecMint is the quickest rising and most trusted neighborhood website for any sort of Linux Articles, Guides and Books on the net. Tens of millions of individuals go to TecMint! to go looking or browse the 1000’s of printed articles obtainable FREELY to all.

If you happen to like what you might be studying, please take into account shopping for us a espresso ( or 2 ) as a token of appreciation.

Support Us

We’re grateful to your by no means ending assist.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments