国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Table of Contents
Different Types of Files in Linux?
Ordinary/Regular Files
Special Files
Linux Block Files
Linux Character Files
Linux Symbolic Link Files
Linux Pipes or Named Pipes
Linux Special Directories
Summary
Home System Tutorial LINUX Everything Is a File and Types of Files in Linux

Everything Is a File and Types of Files in Linux

Jun 18, 2025 am 09:13 AM

If you are new to Linux or have used it for a few months, then you must have heard or read statements such as “In Linux, everything is a File”.

That is in fact true although it is just a generalization concept, in Unix and its derivatives such as Linux, everything is considered as a file. If something is not a file, then it must be running as a process on the system.

To understand this, take for example the amount of space on your root (/) directory is always consumed by different types of Linux files. When you create a file or transfer a file to your system, it occupies some space on the physical disk and it is considered to be in a specific format (file type).

Everything Is a File and Types of Files in Linux

Also, the Linux system does not differentiate between files and directories, but directories do one important job, which is to store other files in groups in a hierarchy for easy location. All your hardware components are represented as files and the system communicates with them using these files.

The idea is an important description of a great property of Linux, where input/output resources such as your documents, directories (folders in Mac OS X and Windows), keyboard, monitor, hard drives, removable media, printers, modems, virtual terminals, and also inter-process and network communication are streams of bytes defined by file system space.

A notable advantage of everything being a file is that the same set of Linux tools, utilities, and APIs can be used on the above input/output resources. Although everything in Linux is a file, there are certain special files that are more than just a file for example sockets and named pipes.

Different Types of Files in Linux?

In Linux there are basically three types of files:

  1. Ordinary/Regular files
  2. Special files
  3. Directories

Ordinary/Regular Files

These are files data contain text, data, or program instructions and they are the most common type of files you can expect to find on a Linux system they include:

  1. Readable files
  2. Binary files
  3. Image files
  4. Compressed files and so on.

Special Files

Special files include the following:

Linux Block Files

These are device files that provide buffered access to system hardware components. They provide a method of communication with device drivers through the file system.

One important aspect of block files is that they can transfer a large block of data and information at a given time.

Listing block files sockets in a directory using the ls command:

<strong># ls -l /dev | grep "^b"</strong>

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 Files

These are also device files that provide unbuffered serial access to system hardware components. They work by providing a way of communication with devices by transferring data one character at a time.

Listing character files sockets in a directory:

<strong># ls -l /dev | grep "^c"</strong>

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
...

A symbolic link is a reference to another file on the system. Therefore, symbolic link files are files that point to other files, and they can either be directories or regular files.

Listing symbolic link sockets in a directory:

<strong># ls -l /dev/ | grep "^l"</strong>

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 can make symbolic links using the ln utility in Linux as in the example below.

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

In the above example, I created a file called file1.txt in /tmp directory, then created the symbolic link, /home/tecmint/file1.txt to point to /tmp/file1.txt.

Linux Pipes or Named Pipes

These are files that allow inter-process communication by connecting the output of one process to the input of another. A named pipe is actually a file that is used by two processes to communicate with each and it acts as a Linux pipe.

Listing pipes sockets in a directory:

<strong># ls -l | grep "^p"</strong>

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 can use the mkfifo utility to create a named pipe in Linux as follows.

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

In the above example, I created a named pipe called pipe1, then I passed some data to it using the echo command, after that the shell became un-interactive while processing the input.

Then I opened another shell and run another command to print out what was passed to the pipe.

# while read line ;do echo "This was passed-'$line' "; done<pipe1>
<h5>Linux Socket Files</h5>
<p>These are files that provide a means of inter-process communication, but they can transfer data and information between processes running on different environments.</p>
<p>This means that sockets provide data and information transfer between processes running on different machines on a network.</p>
<p>An example to show the work of sockets would be a web browser making a connection to a web server.</p>
<pre class="brush:php;toolbar:false"><strong># ls -l /dev/ | grep "^s"</strong>

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

This is an example of a socket created in C by using the socket() system call.

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

In the above:

  • AF_INET is the address family(IPv4)
  • SOCK_STREAM is the type (connection is TCP protocol oriented)
  • 0 is the protocol(IP Protocol)

To refer to the socket file, use the socket_desc, which is the same as the file descriptor, and use read() and write() system calls to read and write from the socket respectively.

Linux Special Directories

These are special files that store both ordinary and other special files and they are organized on the Linux file system in a hierarchy starting from the root (/) directory.

Listing sockets in a directory:

<strong># ls -l / | grep "^d"</strong>

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 etc
drwxr-xr-x root root 4.0 KB Wed Oct  6 22:55:12 2021 home
drwx------ root root  16 KB Wed Oct  6 22:52:31 2021 lost found
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 opt
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 can make a directory using the mkdir command.

# mkdir -m 1666 tecmint.com
# mkdir -m 1666 news.tecmint.com
# mkdir -m 1775 linuxsay.com
Summary

You should now be having a clear understanding of why everything in Linux is a file and the different types of files that can exist on your Linux system.

You can add more to this by reading more about the individual file types and they are created. I hope you find this guide helpful and for any questions and additional information that you would love to share, please leave a comment and we shall discuss more.

The above is the detailed content of Everything Is a File and Types of Files in Linux. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

5 Best Open Source Mathematical Equation Editors for Linux 5 Best Open Source Mathematical Equation Editors for Linux Jun 18, 2025 am 09:28 AM

Are you looking for good software to write mathematical equations? If so, this article provides the top 5 equation editors that you can easily install on your favorite Linux distribution.In addition to being compatible with different types of mathema

SCP Linux Command – Securely Transfer Files in Linux SCP Linux Command – Securely Transfer Files in Linux Jun 20, 2025 am 09:16 AM

Linux administrators should be familiar with the command-line environment. Since GUI (Graphical User Interface) mode in Linux servers is not commonly installed.SSH may be the most popular protocol to enable Linux administrators to manage the servers

Gogo - Create Shortcuts to Directory Paths in Linux Gogo - Create Shortcuts to Directory Paths in Linux Jun 19, 2025 am 10:41 AM

Gogo is a remarkable tool to bookmark directories inside your Linux shell. It helps you create shortcuts for long and complex paths in Linux. This way, you no longer need to type or memorize lengthy paths on Linux.For example, if there's a directory

What is a PPA and how do I add one to Ubuntu? What is a PPA and how do I add one to Ubuntu? Jun 18, 2025 am 12:21 AM

PPA is an important tool for Ubuntu users to expand their software sources. 1. When searching for PPA, you should visit Launchpad.net, confirm the official PPA in the project official website or document, and read the description and user comments to ensure its security and maintenance status; 2. Add PPA to use the terminal command sudoadd-apt-repositoryppa:/, and then run sudoaptupdate to update the package list; 3. Manage PPAs to view the added list through the grep command, use the --remove parameter to remove or manually delete the .list file to avoid problems caused by incompatibility or stopping updates; 4. Use PPA to weigh the necessity and prioritize the situations that the official does not provide or require a new version of the software.

Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux Jul 05, 2025 am 09:25 AM

LXD is described as the next-generation container and virtual machine manager that offers an immersive for Linux systems running inside containers or as virtual machines. It provides images for an inordinate number of Linux distributions with support

How to create a file of a specific size for testing? How to create a file of a specific size for testing? Jun 17, 2025 am 09:23 AM

How to quickly generate test files of a specified size? It can be achieved using command line tools or graphical software. On Windows, you can use fsutilfilecreatenew file name size to generate a file with a specified byte; macOS/Linux can use ddif=/dev/zeroof=filebs=1Mcount=100 to generate real data files, or use truncate-s100M files to quickly create sparse files. If you are not familiar with the command line, you can choose FSUtilGUI, DummyFileGenerator and other tool software. Notes include: pay attention to file system limitations (such as FAT32 file size upper limit), avoid overwriting existing files, and some programs may

How to install Linux alongside Windows (dual boot)? How to install Linux alongside Windows (dual boot)? Jun 18, 2025 am 12:19 AM

The key to installing dual systems in Linux and Windows is partitioning and boot settings. 1. Preparation includes backing up data and compressing existing partitions to make space; 2. Use Ventoy or Rufus to make Linux boot USB disk, recommend Ubuntu; 3. Select "Coexist with other systems" or manually partition during installation (/at least 20GB, /home remaining space, swap optional); 4. Check the installation of third-party drivers to avoid hardware problems; 5. If you do not enter the Grub boot menu after installation, you can use boot-repair to repair the boot or adjust the BIOS startup sequence. As long as the steps are clear and the operation is done properly, the whole process is not complicated.

NVM - Install and Manage Multiple Node.js Versions in Linux NVM - Install and Manage Multiple Node.js Versions in Linux Jun 19, 2025 am 09:09 AM

Node Version Manager (NVM) is a simple bash script that helps manage multiple Node.js versions on your Linux system. It enables you to install various Node.js versions, view available versions for installation, and check already installed versions.NV

See all articles