Learn about the file types and extensions of Linux one day

Source: Internet
Author: User
In the file permission section described in the previous section, we used the ls-l command to view the first character in the first column. in addition to the file types we mentioned earlier, what types of files are there? We also know that in Microsoft's win System, file extensions are an important concept, but in linux systems

In the file permission section described in the previous section, we used the ls-l command to view the first character in the first column. in addition to the file types we mentioned earlier, what types of files are there? We also know that in Microsoft's win System, file extension is an important concept, but in linux systems, this suffix is not so important, although not important, however, this suffix still exists to facilitate management and identification. This is what we will talk about today: file type and suffix.

Common file types in Linux
General files

This is what we listed through ls-l. The first character in the first column is the "-" file, which can be divided into several categories based on the file content:

Plain text file (ASCII): Similar to notepad, it is called a plain text file. we can directly read the content in the file. This type of file occupies a large proportion in Linux.


Binary: the executable file (scripts) in Linux is a binary file, and the file must have the x permission to be executed. Some commands in our system are such files.

Data: In Linux, some programs read certain databases when running. these files are data files. For example, the last command we mentioned earlier calls/var/log/wtmp. if we use the cat command to view the/var/log/wtmp file, you will find it all garbled.

For some other file types, such as connection files, device files, data interface files (sockets), and pipeline files (pipe), these are also some special file types, we only need to know what it is. in the later study, you need to know what it is. If you want to learn more deeply, find relevant information and study it slowly, for example, how to view a data file.

Linux file suffix
We also said at the beginning that on Linux systems, the requirements for this suffix are not as strict as Microsoft's win system, just to facilitate the confirmation of what file is like, the corresponding suffix is added to the end. If a file can use the cat command to read the content, we can still use cat to read the content after modifying the suffix.

We also know that the commonly used executable files on a soft winsystem generally end with .com;.bat;.exe. In our Linux system, it is different. I can add X (executable) permissions to all files, but whether the execution is successful depends on the content of the file. The important point here is that "the execution can be executed differently from the execution can be successful ". For example, we have an install in the root user's home directory. log file. we add the X permission to it. although it is a executable file, there is no result after execution, because the content in this file is not what our system can execute, of course, the execution fails!

So, in order to help us understand what files are in the system. The Linux system still uses the corresponding suffix to indicate the file type. Below we will look at some common suffixes
. Sh: this is usually a script file written by ourselves. it is generally written by shell, so it is represented by. sh.
.Z,.tar,.tar,.gz,.zip and. tgz: These types of files are compressed files, but they only adopt different compression methods.
. Log: These types of files are some log files.
. Conf: these files are some configuration files, which are the most common in Linux.
. Rpm: this is a Red Hat software package. of course, different Linux versions use different software packages with different suffixes.
.Php, .jsp,.html,.css: All files of the website type.
Of course, there are some other suffixes that do not make much sense, just to facilitate identification. let's take a look at them briefly.

 

Naming rules for file name length and file
In RHEL6, the file name length on the ext4 system
If you want to know the maximum length of the file name on a system, you can write a shell script to test the file name,
[Root @ yufei ~] # Cd/tmp/
[Root @ yufei tmp] # vim testfile
Write the following content
#! /Bin/bash
LENTH = 'for I in {1 .. 255}; do for x in a; do echo-n $ x; done; done'
Touch $ LENTH
Save and exit
[Root @ yufei tmp] # chmod + x testfile
[Root @ yufei tmp] #./testfile
At this time, a file named a can be output normally ...... If you change 255 of the above script to 255 and execute the File again, the error message "File name too long" appears. This fully demonstrates:
On RHEL6's EXT4 system, the maximum file name length is 255 characters.

This length is long enough for us to use. In later studies, you will find that on Linux systems, many software names are very long. if one word is entered, it will be a waste of time and sometimes it will be wrong, is this too inconvenient? Of course not. long file names help us know what this file is for (I think so). In fact, it is convenient for us. To prevent us from typing so many words, there is an important function key in the Linux system, that is, the TAB, which plays a complementary role. as long as we play the first few words, then press the TAB, if you press twice, the content related to these words will be displayed. Haha, friends who use Linux don't know this function, or they don't need it, it's too bad!

Naming rules for files in Linux
We know that in Linux, commands are basically used for operations. the shell we use has many special characters, if the file name is the same as the special characters in the shell, it is difficult to do so. so when we name the file, we can easily identify it at the same time, we also want to avoid some special characters, which we will list below for your reference (not to be able to command these characters, but to avoid them ).
-+ *? > <;&! [] | \'"'(){}

From: Yufei blog

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.