File and file extension under Linux

1. The extension of the Linux file;

When it comes to file types, everyone can think of Windows file types, such as file.txt, file.doc, file.sys, file.mp3, file.exe, etc. The file type can be judged based on the file suffix. However, whether a file can be executed in Linux has little to do with the suffix name, it mainly depends on the attributes of the file. But it is necessary for us to understand the suffix of Linux files, especially if we create some files by ourselves, it is better to add the suffix. The purpose of this is only for our convenience in application.

The current Linux desktop environment is as intelligent as Windows, and file types are associated with corresponding programs. When we open a file, the system will automatically determine which application to open. In this respect, there is not much difference between the Linux desktop environment and the Windows desktop.

In Linux, a file with an extension can only represent the association of the program, and it does not mean that the file is executable. From this aspect, the extension of the Linux does not have much meaning.

file.tar.gz file.tgz file.tar.bz2 file.rar file.gz file.zip ... Everyone is familiar with these, they are archive files. Use the corresponding tools to decompress or extract;

Everyone knows file.php, it is a file that can be interpreted with a php language interpreter and can be opened with a browser;

file.so is a library file;

file.doc file.obt This is the file that OpenOffice can open;

... ...

Files created with some tools have different suffixes, depending on what tools we use, such as Gimp, gedit, OpenOffice and other tools. The suffixes of the files created are also different.


2. Linux file type;

Linux file type and Linux file name represent two different concepts. We created through general applications such as file.txt, file.tar.gz, although these files need to be opened with different programs, but when measured in the Linux file type, most of them are regular files (also called ordinary file).

The common types of Linux files are: ordinary files, directories, character device files, block device files, symbolic link files, etc.; now we have a brief description;


2.1 Ordinary documents;

[root@localhost ~]# ls -lh install.log
-rw-r--r-- 1 root root 53K 03-16 08:54 install.log

We use ls -lh to view the attributes of a file, and we can see something like -rw-r--r--. It is worth noting that the first symbol is -. Such files are ordinary files in Linux. These files are generally created with some related applications, such as image tools, document tools, archiving tools... or cp tools. The way to delete such files is to use the rm command;


2.2 Directory;

[root@localhost ~]# ls -lh
总计 14M

-rw-r--r-- 1 root root     2 03-27 02:00 fonts.scale
-rw-r--r-- 1 root root   53K 03-16 08:54 install.log
-rw-r--r-- 1 root root   14M 03-16 07:53 kernel-2.6.15-1.2025_FC5.i686.rpm
drwxr-xr-x 2 1000 users 4.0K 04-04 23:30 mkuml-2004.07.17
drwxr-xr-x 2 root root  4.0K 04-19 10:53 mydir
drwxr-xr-x 2 root root  4.0K 03-17 04:25 Public

When we execute it in a certain directory, we see something similar to drwxr-xr-x. Such a file is a directory. The directory is a special file in Linux. Note that its first character is d. The command to create a directory can use the mkdir command or the cp command. cp can copy one directory to another. Delete with the rm or rmdir command.


2.3 Character device or block device file;

If you enter the /dev directory and list the files, you will see something similar to the following;

[root@localhost ~]# ls -la /dev/tty
crw-rw-rw- 1 root tty 5, 0 04-19 08:29 /dev/tty
[root@localhost ~]# ls -la /dev/hda1
brw-r----- 1 root disk 3, 1 2006-04-19 /dev/hda1

We see that the attribute of /dev/tty is crw-rw-rw-. Note that the first character in front is c, which means a character device file. For example, serial devices such as cats;

We see that the attribute of /dev/hda1 is brw-r-----. Note that the first character in front is b, which means a block device, such as a hard disk, an optical drive, etc.;

This type of file is created with mknode and deleted with rm. Currently, in the latest Linux distributions, we generally do not need to create device files ourselves. Because these files are associated with the kernel.


2.4 Socket file;

When we start the MySQL server, a mysql.sock file will be generated.

[root@localhost ~]# ls -lh /var/lib/mysql/mysql.sock
srwxrwxrwx 1 mysql mysql 0 04-19 11:12 /var/lib/mysql/mysql.sock

Note that the first character of the attributes of this file is s. We just need to find out.


2.5 Symbolic link files;

[root@localhost ~]# ls -lh setup.log
lrwxrwxrwx 1 root root 11 04-19 11:18 setup.log -> install.log

When we check the file properties, we will see something like lrwxrwxrwx. Note that the first character is l. This type of file is a link file. Is the new file name via ln -s source file name. The above is an example, which means that setup.log is a soft link file of install.log. How to understand it? This is similar to the shortcut in the Windows operating system.

Examples of how to create symbolic link files;

[root@localhost ~]# ls -lh kernel-2.6.15-1.2025_FC5.i686.rpm
-rw-r--r-- 1 root root 14M 03-16 07:53 kernel-2.6.15-1.2025_FC5.i686.rpm
[root@localhost ~]# ln -s kernel-2.6.15-1.2025_FC5.i686.rpm  kernel.rpm
[root@localhost ~]# ls -lh kernel*
-rw-r--r-- 1 root root 14M 03-16 07:53 kernel-2.6.15-1.2025_FC5.i686.rpm
lrwxrwxrwx 1 root root  33 04-19 11:27 kernel.rpm -> kernel-2.6.15-1.2025_FC5.i686.rpm


3. About this article;

   Whether a file can be executed in the Linux environment has nothing to do with the suffix name, but mainly depends on the attributes of the file. But it is necessary for us to understand the suffix of Linux files, especially if we create some files by ourselves, it is better to add the suffix. The purpose of this is only for our convenience in application.

     The current Linux desktop environment is as intelligent as Windows, and file types are associated with corresponding programs. When we open a linux file, the system will automatically determine which application to open. In this respect, there is not much difference between the Linux desktop environment and the Windows desktop.
     In Linux, a file with an extension can only represent the association of the program, and it does not mean that the file is executable. From this aspect, the extension of the Linux does not have much meaning.

 

Common file extensions under Linux


*.php ------Everyone knows this, it is a file that can be explained by a php language interpreter and can be opened by a browser;
*.so -------This type of file is a library file;
* .doc *.obt --------This is the file that OpenOffice can open;

.bz2 ------bzip2 compressed file

.gz ------gzip compressed file

.tar ------tar package file (a package file not a compressed file)

.tbz------tar package and bzip compressed file

.tgz-----tar packaged and gzip compressed file

.au -----audio file

.gif -----gif image file

.html / .htm ----- HTML text

.jpg-----JPEG image file

.pdf------electronic document (PDF format)

.png-----PNG image file

.ps------postscinpt file (print format file)

.txt------plain text file

.wav-----audio file

.xpm-----image file

.conf-------Configuration file

.lock-------LOCK file (used to determine whether a file or device is used)

.rpm------REDHATPackage.Manager file (kit package or software package)

.c -------C source code file

.cpp------C++ source code file

.h -------C or C++ program header file

.o------Program object file

.pl------perl script file

.so-----Class library file

 

The following is a detailed explanation of some suffixes:

1.*.sh

  sh is a linux, unix command, purpose: to call the default shell. Syntax: Please refer to the syntax of the ksh command. Link the /usr/bin/sh file to the Korn shell. Description: The sh command invokes the default shell and uses its syntax and flags. The shell linked to the /usr/bin/sh path is the default shell. The standard configuration of the operating system links the /usr/bin/sh path to the Korn shell. For specific information about Korn shell functions, please refer to "Korn Shell or POSIX Shell Commands" in "AIX 5L V5.2 System User Guide: Operating System and Equipment". Flags: See the flags of the Korn shell (ksh command).

  File: /usr/bin/sh contains sh commands.

 

2.*.cfg

     This is just a suffix name "invented" for the convenience of development and use. This kind of file has no fixed format, and its purpose is only to save the user's settings. Generally read-only, it can also be used for reading and writing.

     Also, for convenience, the content inside is indeed text most of the time. It can be opened with any text editor. Source insight is used in this example.

     Files in smart phones: CFG is a boot file, CFG and TFS files are placed in the same folder, which is equivalent to the header file in the program. The cfg file of tfs can be generated by the resource manager.

      The CFG (Config) script file is generally used for programs to read specified values. The following is a common format:
Example:

102 (Home)
115 (VolumeUp)
114 (VolumeDown)
248 (Reading)
158 (Back)
139 (Menu)
end

3. * .ko

   It is the suffix name of the dynamic link file used by the Linux 2.6 kernel, that is, the module file, which is used to load the kernel module when the Linux system starts, usually a driver.

   load:

   modprobe module-name or insmod /path-to/module-name.ko
   But it should be noted that this module can only be used when compiled under a library and kernel version similar to your system environment, otherwise an error will occur.

 

 

 

4. *.conf

    Program configuration file, start netmeeting

    The configuration files in the application system are widely used in unix-like systems, and most software that has both windows and unix-like system versions are also used

 

5. *.allow and *.deny


     The two files /etc/hosts.allow and /etc/hosts.deny are the configuration files of the tcpd server. The tcpd server can control the access of external IP to the local service. The format of these two configuration files is as follows:
    #Service process name: Host list: optional command operation when the rule matches
    server_name:hosts-list[:command]
 

     /etc/hosts.allow controls the ip address that can access the machine,

     /etc/hosts.deny controls the IP that prohibits access to this machine.

     If the configuration of the two files conflict, take /etc/hosts.deny as the standard. The following is an example of /etc/hosts.allow:
ALL:127.0.0.1 #Allow this machine to access all service processes of this machine
smbd:192.168. 0.0/255.255.255.0 #Allow the IP of the 192.168.0. network segment to access the smbd service. The
ALL keyword matches all cases, EXCEPT matches except for certain items, and PARANOID matches the IP address you want to control and its domain name does not match Time (domain name disguise) situation.

 

6. *.types

   When encountering a file with two suffixes, check whether the file with two suffixes is defined in the file, so as to select the appropriate file processing method.

   This file controls what Internet media types are sent to the client for given file extension(s).

    Whenever it encounters a file with a double suffix name (such as xxx.php.rar), Apache will check the last suffix in the conf/mime.types file. If the last suffix is ​​not defined in the mime.types file, then Use the previous suffix to explain, because by default, rar is not defined in mime.types, so Apache will use the php suffix to interpret files. (This is the cause of the vulnerability)

 

7. *.rc

    The file with the extension of rc in VC is called resource script file, which contains all the windows resources used in the application. The rc file can be directly edited and modified in a visual way in the VC integrated environment.

8. *.so

   In the Linux environment, the suffixes of the library files compiled by C++ include: .so or .a or .la. Of course, the file type under linux does not depend on its suffix name, and the suffix and its meaning:
.so is a shared library: dynamic Library (shared library/shared object/dynamic link library)

.so.1, .so.6, etc.: the latter is the version only, these are all dynamic runtime libraries, most of which belong to the basic library, namely glibc.

.a is a static library: archive / static library
.la is some shared libraries automatically generated by libtool, which can be edited and viewed with vi, which mainly records some configuration information. You can use the following command to view the format of the *.la file file *.la

Guess you like

Origin blog.csdn.net/hn_tzy/article/details/89133720