In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains the "introduction of file types and file extensions in the Linux system", the content of the explanation is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in-depth, together to study and learn "the introduction of file types and file extensions in the Linux system"!
one。 File type
Linux file types are common: ordinary files, directory files, character device files and block device files, symbolic link files and so on. Now let's give a brief description.
1. Ordinary document
When we use ls-lh to look at the properties of a file, we can see that there is something like-rwxrwxrwx. It is worth noting that the first symbol is -, which is a normal file in Linux. These files are generally created with related applications, such as image tools, documentation tools, archiving tools. Or cp tools, etc. Such files are deleted using the rm command. In addition, according to the contents of the document, it can be roughly divided into:
1 >. Plain text (ASCII):
This is the most common file type in the Linux system, and it is called plain text because the content is data that we humans can read directly, such as numbers, letters, and so on. Almost any file that we can use as a setting belongs to this type of file. For example, you can use the command: cat ~ /. Bashrc to see the contents of the file. Cat is an instruction to read out the contents of a file.
2 >. Binary file (binary):
The Linux system actually only knows and can execute binaries (binary file). Executable files (scripts, excluding text batch files) in Linux are files in this format. The command cat you just used is a binary file.
3 >. Data format file (data):
Some programs read files in certain formats in the course of operation, and those files in specific formats can be called data files (data file). For example, when a user logs in, our Linux will record the login data in the / var/log/wtmp file, which is a data file, and he can read it through the last command! But when using cat, it will read the garbled code ~ because it belongs to a special format of the file?
two。 Catalog file
When we execute in a directory, we see a file like drwxr-xr-x, which is a directory, and a directory is a special file in Linux. Notice that its first character is d. The command to create a directory can use the mkdir command or the cp command, and cp can copy one directory to another. Delete with the rm or rmdir command.
3. Character device or block device file
If you go to the / dev directory and list the files, you will see something like this:
The code is as follows:
[root@localhost ~] # ls-al / dev/tty
Crw-rw-rw- 1 root tty 5, 0 11-03 15:11 / dev/tty
[root@localhost ~] # ls-la / dev/sda1
Brw-r- 1 root disk 8, 1 11-03 07:11 / dev/sda1
We see that the attribute of / dev/tty is crw-rw-rw-, and notice that the first character is c, which represents the character device file. Serial devices such as cats. We see that the attribute of / dev/sda1 is brw-r-, and notice that the first character before it is b, which indicates a block device, such as a hard disk, optical drive, and so on.
This kind of file is created with mknode and deleted with rm. Currently, in the latest Linux distribution, we generally don't have to create device files ourselves. Because these files are associated with the kernel.
Some files related to the perimeter and storage of the system are usually concentrated in the / dev directory! It is usually divided into two categories:
Block (block) device file:
Just some interface devices that store data to provide random access to the system, for example, hard drives and floppy disks. You can randomly read and write in different blocks of the hard disk, this kind of device is the group device! You can check / dev/sda yourself and you will find that the first attribute is [b]!
Character (character) device file:
That is, some serial port interface devices, such as keyboard, mouse and so on! The characteristic of these devices is that they are read at once and cannot truncate the output. For example, you can't let the mouse jump to another screen, but slide to another place! The first attribute is [c].
4. Data Interface File (sockets):
Data interface file (or: socket file), this type of file is usually used to receive data on the network. We can start a program to listen to the client's request, and the client can communicate with the data through this socket. The first attribute is [s], which is most commonly seen in the / var/run directory.
For example, when we start the MySQL server, a mysql.sock file is generated.
The code is as follows:
[root@localhost ~] # ls-lh / var/lib/mysql/mysql.sock
Srwxrwxrwx 1 mysql mysql 0 04-19 11:12 / var/lib/mysql/mysql.sock
Notice that the first character of the attribute of this file is s.
5. Symbolic link file:
When we look at the file properties, we will see something like lrwxrwxrwx. Notice that the first character is l, and this type of file is a linked file. Is through the ln-s source file name new file name. The above is an example that indicates that setup.log is a soft link file for install.log. How do you understand it? This is somewhat similar to shortcuts in the Windows operating system.
Examples of how to create symbolic link files:
The code is as follows:
[root@localhost test] # ls-lh log2012.log
-rw-r--r-- 1 root root 296K 11-13 06:03 log2012.log
[root@localhost test] # ln-s log2012.log linklog.log
[root@localhost test] # ls-lh * .log
Lrwxrwxrwx 1 root root 11 11-22 06:58 linklog.log-> log2012.log
-rw-r--r-- 1 root root 296K 11-13 06:03 log2012.log
6. Data transfer file (FIFO,pipe):
FIFO is also a special file type, its main purpose is to solve the error problem caused by multiple programs accessing a file at the same time. FIFO is the abbreviation of first-in-first-out. The first attribute is [p].
two。 Linux file extension
1. Extension type
Basically, there is no extension for Linux files. Whether a Linux file can be executed or not is related to its ten attributes in the first column and has nothing to do with the file name at all. This concept is different from that of Windows. Under Windows, the file extension that can be executed is usually .com .exe. Bat, etc., while under Linux, as long as you have x in your permissions, for example, [- rwx-r-xr-x] means that the file can be executed.
However, being able to be executed is not the same as being able to execute successfully ~ for example, install.log in the root home directory is a plain text file. If you change the permission to-rwxrwxrwx, can this file really be executed successfully? Of course not ~ because there is no enforceable data in his content. Therefore, this x represents the executable ability of the file, but whether it can be executed successfully or not depends on the content of the file.
Even so, we still want to know what the file is by extension, so we usually use the appropriate extension to indicate what kind of file it is. There are several common extensions below:
* .sh: script or batch file (scripts), because the batch file is written using shell, so the extension is .sh
* Z, * .tar, * .tar.gz, * .zip, * .tgz: a packaged compressed file. This is because the compression software is gunzip, tar, etc., due to different compression software, and take its related extension!
* .html, * .php: Web page-related files that represent HTML syntax and PHP syntax, respectively. HTML files can be opened directly using a web browser, while .php files can be browsed on the server side through a browser on the client side to get the calculated web page results.
Basically, the file name on the Linux system really just lets you know what the file might be used for, and whether it is actually executed or not still requires permission specifications. For example, although a file is executable, such as the common / bin/ls directive that displays file properties, ls becomes unexecutable if the permissions of the file are modified to be unexecutable.
The above problems most often occur in the process of file transfer. For example, you download an executable file on the network, but it just can't be executed in your Linux system! He he! Then it is possible that the properties of the file have been changed. There is no doubt that the properties and permissions of files will be changed when they are transferred from the network to your Linux system.
2. Length limit of Linux file name:
Under Linux, when using the preset Ext2/Ext3 file system, the file name length is limited to:
The maximum allowable file name for a single file or directory is 255 characters
The full file name containing the full path name and directory (/) is 4096 characters.
It's a pretty long file name! We hope that the file name of Linux can tell what the file is doing at a glance, so the file name is usually very long.
3. Restrictions on characters of Linux file names:
Because of some instructions and operations of Linux under the text interface, generally speaking, when you set the file name under Linux, it is better to avoid some special characters! For example, the following:
*? > <; &! [] |\'"`() {}
Because these symbols have a special meaning under the text interface. In addition, the file name begins with the decimal point. Represents this file as a hidden file! At the same time, since options such as-option are often used in instructions, it is best to avoid naming the file name at the beginning with-or +.
Thank you for your reading, the above is the "introduction of file types and file extensions in the Linux system". After the study of this article, I believe you have a deeper understanding of the introduction of file types and file extensions in the Linux system, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.