Permission parsing for CentOS system structure file attributes

Source: Internet
Author: User
Tags temporary file storage ide hard drive

Permission parsing for CentOS system structure file attributes
I. Linux hard disk partitioning and system structure:


The root directory 1./bin is short for binary and contains the commands required for boot, and the commands that common users may use (possibly after boot ). These commands are executable programs of binary files, mostly important system files in the system.
2./sbin
Similar to/bin, it is also used to store binary files. Most of these files are the basic system programs used by the system administrator. Although common users can use them when necessary, they are generally not used by common users.
3./etc stores system management configuration files, including user information files/etc/passwd and system initialization files/etc/rc. Linux runs properly only through these files.
/Etc/rc or/etc/rc. d or/etc/rc ?. D: The Directory of scripts or scripts that start or change at the running level.
/Etc/passwd: user database, where the domain provides the user name, real name, user start directory, encrypted password, and other user information.
/Etc/fdprm: floppy disk parameter table to describe different floppy disk formats. Setfdprm can be used for setting. For more information, see the Help page of setfdprm.
/Etc/fstab: Specifies the list of file systems to be automatically installed at startup. It also includes information about the swap zone enabled with swapon-.
/Etc/group: similar to/etc/passwd, but it does not indicate user information but group information. Including various data of the group.
/Etc/inittab: the configuration file of init.
/Etc/issue: includes the user's output information before the logon prompt. It usually includes a short description or welcome information of the system. The specific content is determined by the system administrator.
/Etc/magic: "file" configuration file. It contains descriptions of different file formats. "file" is used to guess the file type.
/Etc/motd: motd is the abbreviation of messageoftheday. It is automatically output after the user logs on successfully. The content is determined by the system administrator. It is often used for notification information, such as warning about the scheduled shutdown time.
/Etc/mtab: List of currently installed file systems. It is initialized by the script (scrui) and automatically updated by the mount command. Use (such as the df command) when you need a list of currently installed file systems ).
/Etc/shadow: the shadow password file on the system where the shadow password software is installed. The shadow password file moves the encrypted password in the/etc/passwd file to the/etc/shadow file, which is only readable to the root user. This makes password deciphering more difficult to increase system security.
/Etc/login. defs: configuration file of the login command.
/Etc/printcap: similar to/etc/termcap, but for printers. Different syntaxes.
/Etc/profile,/etc/csh. login,/etc/csh. cshrc: Files executed by bourne or cshells at login or startup. This allows the system administrator to create a global default environment for all users.
/Etc/securetty: confirm the security terminal, that is, the terminal that allows the Super User (root) to log on. Generally, only the virtual console is listed, so that it is impossible (at least difficult) to break into the system through a modem or network and obtain super user privileges.
/Etc/shells: list the shells that can be used. The chsh command allows you to change the logon shell within the specified range of this file. The ftpd service process that provides an ftp service on a machine checks whether the user's shell is listed in the/etc/shells file. If not, the user is not allowed to log on.
/Etc/termcap: terminal performance database. Describes the escape sequence used by different terminals. When writing a program, the escape sequence is not output directly (this can only work on terminals of a specific brand), but the correct sequence of the work to be done is searched from/etc/termcap. In this way, most programs can run on most terminals.

4./root Super User directory.
5./lib shared libraries required by the Program on the root file system, which stores the shared files required by the root file system program. These files contain code that can be shared by many programs, so that each program contains copies of the same subroutine, so that the executable files can be smaller and save space. It is also called the standard programming library, or the dynamic link shared library, which works similar to the. dll file in windows.
6./lib/modules contains the system core which can be loaded with various modules, especially those required to reboot the system (such as network and file system drivers) when restoring the damaged system ).
7./dev stores the device files, that is, the device driver. You can use these files to access external devices. For example, you can access the mouse input by accessing/dev/mouse, just like accessing other files.
/Dev/console: the system console, that is, the monitor directly connected to the system.
/Dev/hd: ide Hard Drive Interface. For example,/dev/hda indicates the first hard disk and had1 indicates the first partition of/dev/hda. If there are other hard disks in the system, they are/dev/hdb,/dev/hdc ,......; if multiple partitions exist, they are hda1 and hda2 ......
/Dev/sd: scsi disk driver interface. If the system has a scsi hard disk, it will not access/dev/hda, but/dev/sda.
/Dev/fd: Driver of the drive device. For example,/dev/fd0 indicates the first floppy disk of the system, that is, a: disk,/dev/fd1 indicates the second floppy disk ,...... the/dev/fd1h1440 indicates accessing the 4.5 high-density disk in drive 1.
/Dev/st: scsi tape drive driver.
/Dev/pty: supports remote logon to pseudo terminals. The/dev/pty device is required for telnet login.
/Dev/ttys: computer serial interface, which is the "com1" port for dos.
/Dev/cua: The serial interface of the computer, which is used with the modem.
/Dev/null: "black hole". All information written to this device will disappear. For example, to hide the output information on the screen, you only need to input the output information to/dev/null.

/Dev/ttynn directly connected terminal
/Dev/ttyxnn Multi-Channel Terminal (x is typically a, B, etc)
/Dev/ptsnnn X Windows system and network pseudo Devices
The general name of the/dev/fd0 floppy disk device.
/Dev/ftape connect to the tape device
/Dev/cdrom normally connects to CD-ROM Devices
/Dev/lp0 printer parallel port
/Dev/tty: supports the virtual console. For example,/dev/tty1 indicates the first virtual console of the system, and/dev/tty2 indicates the second virtual console of the system. Tty0 is an alias or link of tty1 or ttyn. Why? When we use tty0, the sub-device number is 0. Therefore, in the macro TTY_TABLE, we will get the terminal device tty_table [fg_console. Fg_console is the subscript of the current terminal device in the tty_table array. This macro finds the ttyn corresponding to tty0, reads the keyboard, and writes the display to ttyn.

8./tmp public temporary file storage point, which stores the information and data generated by the program during running. However, after boot, it is best to use/var/tmp to replace/tmp for running programs, because the former may have a larger disk space.
9./boot stores some core files used to start Linux. bootstrap loader such as lilo will use these files, which are first loaded when the computer starts. This directory also contains the Linux kernel, but the Linux kernel can also be stored elsewhere, as long as LILO is configured and LILO knows where the Linux kernel is. Stores the files used by the bootstraploader, such as lilo. The core images are often stored here, rather than in the root directory. However, if there are many core images, this directory may become very large, and it would be better to use a separate file system. Note that the core image must be in the first 1024 cylinder of the ide hard disk.
10./The mnt directory is empty. When the system provides this directory, users can temporarily Mount other file systems. System Administrator temporary installation (mount) File System Installation Point. The program does not automatically support installation to/mnt. /Mnt can be divided into many sub-directories. For example,/mnt/dosa may be a soft drive using the msdos file system, while/mnt/exta may be a soft drive using the ext2 file system, /mnt/cdrom may be an optical drive.
11./proc this directory is a virtual directory, which is the ing of system memory. You can directly access this directory to obtain system information. That is to say, the contents of this directory are not in the hard disk but in the memory.
/Proc/x: The information directory of process x. Here, x indicates the ID of the process. Each process has a directory named its own process number under/proc.
/Proc/cpuinfo: stores information about the cpu, such as the cpu type, manufacturer, model, and performance.
/Proc/devices: List of device drivers with core configurations currently running.
/Proc/dma: displays the currently used dma channel.
/Proc/filesystems: The file system information of the core configuration.
/Proc/interrupts: displays the information of the interrupted and occupied users, and the number of occupied users.
/Proc/ioports: the currently used I/o port.
/Proc/kcore: physical memory image of the system. It is identical to the physical memory size, but it does not actually occupy so much memory; it is created only when the program accesses it. (Note: Unless you copy it to somewhere, nothing in/proc occupies any disk space .)
/Proc/kmsg: Core Output Message. It will also be sent to syslog.
/Proc/ksyms: Core symbol table.
/Proc/loadavg: average system load. Three meaningless indicators indicate the current workload of the system.
/Proc/meminfo: memory usage information, including physical memory and swap partition (swap ).
/Proc/modules: stores information about the core modules currently loaded.
/Proc/net: network protocol status information.
/Proc/self: stores the symbolic connection to the process directory of the program you want to view/proc. When two processes view/proc, this will be a different connection. This allows the program to obtain its own process directory.
/Proc/stat: the status of the system. For example, the number of page errors after the system is started.
/Proc/uptime: the duration of system startup.
/Proc/version: core version.

12./usr the largest directory. Almost all the applications and files to be used are in this directory.
/User/x11r6: directory for storing x Windows. Contains all executable programs, configuration files, and support files of the xwindow system. To simplify the development and installation of x, x files are not integrated into the system. The xwindow system is a powerful graphic environment that provides a large number of graphic tool programs. If you are familiar with Microsoft Windows or machine learning, you will not feel helpless about the xwindow system.
/Usr/x386: similar to/usr/x11r6, but it is dedicated to x11release5.
/User/bin: a large number of applications. A collection of almost all user commands is a software library of the system. Some other commands are in/bin or/usr/local/bin.
/User/sbin: hyperuser management program. Includes unnecessary system management commands for the root file system, such as most service programs.
/User/doc: linux document
/User/include: header files required for developing and compiling applications in linux. Contains the header file of C language. These files end with. h and are used to describe the data structures, subprocesses, and constants used in C language programs. In order to maintain consistency, this should be put under/usr/lib, but this name has always been used.
/Usr/lib common dynamic link library and software package configuration files. Contains unchanged data files of programs or subsystems, including some site-wide configuration files. The name lib comes from the library. The original library for programming also exists in/usr/lib. When you compile a program, the program will be connected to the library. Many programs store configuration files.
/Usr/man help document
/Usr/src: linux open source code. For example, the source code of linux kernel is stored in/usr/src/linux.
/Usr/local: The locally installed software and other files are stored here. This is similar to/usr. You may find some large software packages, such as tex and emacs.
/Usr/local/bin commands added locally
/Usr/local/lib: locally added Library
13./var overflow of some large files, such as log files of various services.
/Var/catman: contains the formatted help (man) page. The source file of the Help Page usually exists in/usr/man; some man pages may have pre-formatted versions, which exist in/usr/man/cat. Other man pages must be formatted when they are viewed for the first time. The formatted version exists in/var/man, so that other people do not have to wait for the same page to be formatted. (/Var/catman is often cleared, just like clearing a temporary directory .)
/Var/lib: stores the files to be changed when the system is running normally.
/Var/local: stores variable data of programs installed in/usr/local (that is, programs installed by the system administrator ). Note: if necessary, other/var directories, such as/var/lock, will be used even for locally installed programs.
/Var/lock: lock the file. Many programs follow the Convention of generating a locked file in/var/lock to support the use of a specific device or file. Other programs will no longer use this device or file when they notice this locked file.
/Var/log: log files of various programs, especially login (/var/log/wtmplog records all logon and logout to the system) and syslog (/var/log/messages records store all core and system program information ). Files in/var/log often grow uncertain and should be cleared regularly.
/Var/run: Save the system information files that are valid before the next system boot. For example,/var/run/utmp contains the information of the user currently logged on.
/Var/spool: directory of the "spool" program, such as mail, news, print queue, and other queue working directories. Each different spool has its own sub-directories under/var/spool. For example, users' mailboxes are stored in/var/spool/mail.
/Var/tmp: a temporary file that is larger than/tmp or needs to exist for a long time. Note that the system administrator may not allow/var/tmp to have very old files. 14./home installation of other file systems.
15. The/Lost + found directory is usually empty. When the system is not shut down normally, it becomes a shelter for some homeless files.


2. in Linux, different types of file attributes are marked in different colors. Generally, there are the following types of attributes:

Blue: indicates the directory light blue: indicates the link file Green: indicates the executable file RED: indicates the compressed file Gray: indicates other files Yellow: indicates the device file (including block, char, fifo) red flashing: indicates that the link file is faulty.


Column 1: type and permission (permission ):
These words are displayed when you use the ll or ls-la command in linux. These words represent permissions for different user groups:


There will be a total of 10 "-", the first indicates the file type:
D folder, for example, the line named. gconf in the above table;
-File, for example, the line named install. log in the preceding table;
L link file );
Device B file, which contains interface equipment for storage (random access device );
Serial Port Devices in Device c files, such as the keyboard and mouse (one-time reading device)

The following nine items are divided into three groups, namely, the first three indicate the owner permissions, the middle three indicate the same group of user permissions, and the last one indicates the permissions of other users (other users, does not include the root super user ).

R: read is the read permission. The value 4 in decimal format indicates that the binary number is 100.
W: write is the write permission -- decimal number 2 indicates the binary number is 010

X: excute is the execution permission. The decimal number 1 indicates that the binary number is 001.

The read, write, and run permissions can be represented by numbers, that is, r = 4, w = 2, x = 1. Therefore,-rw-r -- is expressed as 644 in numbers.
For example,-rwxrwx ---, that is, the 770 permission indicates that this file (folder) has the read and write permissions and the same group of users. Other user groups do not have any permissions.

• Special permissions SUID, SGID, SBIT:



Set UID:
When the s mark appears on the x permission of the file owner, the permission status of the file above/usr/bin/passwd is called Set UID, special permissions for SUID. Basically, SUID has the following restrictions and functions:

• The SUID permission is only valid for binary program (not enough for shell scripts)
• The operator must have x runability for the program
• This permission is only valid during running of the Program (run-time)
• The operator will have the permissions of the owner of the program.

Take the passwd file as an example:

Vbird has the x permission for the/usr/bin/passwd program, indicating that vbird can run passwd;
The owner of passwd is the root account. When vbird runs passwd, it will "Temporarily" Get the root permission;
/Etc/shadow can be modified by the passwd run by vbird.
But can vbird read/etc/shadow through cat? Because cat does not have SUID permission, when vbird runs "cat/etc/shadow", it cannot read/etc/shadow. Here is a description:
Figure 4.4.1 SUID program running process


SGID:
Unlike SUID, SGID can be configured for files or directories!
For files, SGID provides the following functions:
• SGID is useful for Binary programs. For programs that run programs, you must have the x permission.
• During the running process, the runner will obtain the permissions of the program group. If the target directory is located, SGID has the following functions:
• If the user has the r and x permissions for this directory, the user can access this directory;
• The valid group in this directory will be changed to the group in this directory;
Sticky Bit:
This Sticky Bit, SBIT currently only applies to directories:
• When the user has w and x permissions for this directory, that is, the user has write permission;
• When a user creates a file or directory in this directory, only the user and the root user have the right to delete the file. In other words: when user A has the identity of A group or another person and has the permissions of directory w, this indicates that "a user can delete, rename, or move any directory or file created by anyone in this directory. 』 However, if you add the SBIT permission project to directory A, you can only delete, rename, or move the files or directories you have created, but cannot delete others' files.



User, group, and others do not have the x runnable sign (because 666). Therefore, this S, T represents "null 』

Column 2: How many files are connected to this node (I-node)

Records how many different file names are linked to the same I-node (each file records its permissions and attributes to the I-node of the file system. However, the directory tree we use is recorded by file name, so each file name is linked to an I-node)

Column 3: owner of a file (or directory)

Column 4: group to which the file belongs

In Linux, the next account is attached to one or more groups (assume that the group to which a file belongs is projecta and the permission of the file (-rwxrwx ---), then class1, the class2 and class3 users have the readable, writable, and executable permissions on the file (view group permissions ). however, if it is not another account of projecta, it does not have any permissions for this file)

Column 5: file size (default unit: bytes)

Column 6: file creation date or latest modification date

The content in this column is the date (month/day) and time. If the modification time of this file is too long, the time section will only show the year:

Column 7: full file path and file name

This field is the file name. it is special: if there is one more file name before the file name 『. ", indicates that this file is" hidden file ", which is shown in the table above. in the gconf line, the file is hidden. you can use "ls" and "ls-a" to show hidden documents.

Hide attributes

In addition to the basic r, w, and x permissions, in the Linux Ext2/Ext3 file system, we can also configure other system hidden attributes. however, the following chattr command takes effect only on the Ext2/Ext3 file system. Other file systems may not support this command. let's talk about how to configure and check these hidden attributes!

Chattr (configuration file hidden attribute)

This command is very important, especially in the data security of the system! Because these properties are hidden properties, you must use lsattr to see this property! I personally think that the most important attribute is + I and +. + I can prevent a file from being changed. For those who need strong system security, it is really important! There are many other properties that need to be configured by the root user!

In addition, if it is a log file login file, you need to add + a, but you cannot modify the old data and delete parameters! How? Great! In the future, we will talk about how to configure the logon file (Chapter 19!

Lsattr (show file hidden attributes)

After configuring chattr, you can use lsattr to view hidden attributes. however, these two commands must be very careful in use, otherwise it will cause a lot of trouble. for example, if one day you are in a good mood and suddenly configure the important password record file/etc/shadow as an I attribute, then after several days, you will suddenly add new users, but cannot be added all the time! Don't doubt, please remove the I attribute!

Modify file attributes[Chgrp] [chown] [chmod] [umask] chgrp: Change the group to which the file belongs.

Chown: Change the file owner


When you copy a file to someone other than you, because of the copy behavior (cp), the attributes and permissions of the performer will be copied, so others will not be able to use the file you copied to him, so you need to change the owner and group of the file.

Chmod: changes the access permissions of files or directories, including SUID, SGID, and SBIT. This command has two usage methods:

Number setting method: syntax format: chmod [mode] File Name

The key is the mode value. At first many beginners will be confused. In fact, it is very simple. We regard rwx as a binary number. If there is 1, there is 0. Then rwx r-x r--can be expressed as: 111 101 100, and then each three digits are converted into a decimal number, that is, 754.


For example, we want the permission for the.txt file to be:

Other users in the same group
Read/write

Then, we first obtain the permission string rw-r -- Based on the table above, and convert it to the binary number 110 110 100, and then convert each three digits into a decimal number, you will get 6 (yourself) 6 (same group of users) 4 (other users ).

Therefore, run the command chmod 664 a.txt.

The score of each permission is as follows:

SUID: 4
SGID: 2
SBIT: 1
R: 4
W: 2
X: 1

The scores of the three special permissions (r/w/x) for each identity (SUID/SGID/SBIT) and (owner/group/others) need to be accumulated.

For example, if the permission is [-rwx ---], the score is:
Owner = rwx = 4 + 2 + 1 = 7
Group = rwx = 4 + 2 + 1 = 7
Others = --- = 0 + 0 + 0 = 0

For example, if the permission is [-rwsr-sr-x], the score is:

Special Permission = SUID & SGID = 4 + 2 = 6
Owner = rws = 4 + 2 + 1 = 7
Group = r-s = 4 + 1 = 5
Others = r-x = 1 = 5

So when we change the permission settings, the permission number for this file is 770! The command chmod syntax for permission change is as follows:

File Permission for changing the symbol type: syntax format: chmod [who] [opt] [mode] File/directory name

Who indicates an object, which is one or a combination of the following letters:
U: indicates the file owner.
G: indicates the same group of users.
O: other users
A: indicates all users.

Opt indicates the operation, which can be:
+: Add a permission.
-: Cancel a permission.
=: Grant the given permissions and cancel the original permissions.

Mode indicates the permission:
R
W
X

There is also a way to change permissions. From the previous introduction, we can find that the nine permissions are (1) user (2) group (3) others. Then we can use u, g, o to represent the permissions of three identities. In addition, a represents all identities. The read and write permissions can be written as r, w, and x. SUID is u + s, SGID is g + s, and SBIT is o + t. That is to say, you can use the following method:Chmodu
G
O
A + (join)
-()
= (SET) r
W
X file or directory

Let's implement it! If we want to "set" the permission for a file to become "-rwxr-xr-x", it is basically:

User (u): Has the readable, writable, and executable permissions;
Group and others (g/o): have the permission to read and execute.

So:

For example, add the read and write permissions for file a.txt to users in the same group:

Chmod g + rw a.txt


Default file permission: umask

Umask is to specify the "Default User permission when creating a file or directory 』

The umask score refers to the "permission to be removed by default !』 Because r, w, and x are 4, 2, and 1 points

On the default permission attributes, directories and files are different. The x permission is very important for directories! However, normal file creation should not have the permission to run. The default situation is as follows:

If the user creates a file, the default "no running (x) Permission" means that only rw projects, that is, the maximum value is 666 points.
If the user creates a "directory", x is related to whether the user can access the directory. Therefore, all permissions are enabled by default, that is, 777 points.

Example:
Assume that your umask is 003. In this case, what is the permission for creating files and directories?
A:
Umask is 003, so the acquired permission is -------- wx. Therefore:
File: (-rw-)-(-------- wx) =-rw-r --
Directory: (drwxrwxrwx)-(-------- wx) = drwxrwxr --

Iii. Permission meaning of directories and files

[Meaning of permissions on files] [meaning of permissions on directories]

Meaning of permissions on files:
  • R (read): read the actual content of the file, such as the text content of the text file;
  • W (write): You can edit, add, or modify the content of the file (but not delete the file );
  • X (execute): The file has the permission to be executed by the system.
    Whether a file under Windows can be executed is determined by the "extension", such as. exe,. bat,. com, etc.
    In Linux, whether a file can be executed is determined by whether it has the "x" permission! There is no absolute relationship with the file name.

Meaning of permissions on directories:
  • R (read contents in directory ):
    Indicates that you have the permission to read the list of directory structures. Therefore, when you have the permission to read (r) a directory, You can query the file name data in this directory. so you can use the ls command to display the content list of this directory!
  • W (modify contents of directory ):
    1. Create a new file and directory;
    2. Delete an existing file and directory (regardless of the permission of the file !)
    3. Rename an existing file or directory;
    4. Move the files and directories in the directory.
  • X (access directory ):
    You have the permission to enter this directory to become a working directory.

It can be seen that if a person wants to enter the directory, he must have the permission of x but only the permission of x to enter the directory is meaningless, because you cannot read files in the directory. therefore, if you want to allow an individual to access this directory and read the file structure under the directory, you must have the permissions x and r.

Iv. Linux File Types and extensions

[File type] [Linux File Extension] [Linux File length limit]

We have been emphasizing the concept in the basic article that any device is a file under Linux.

File Type:
  • Regular file (regular file): a file of the type we normally access. The first character of the attribute displayed by ls-al is [-], for example, [-rwxrwxrwx]. in addition, according to the content of the file, it can be divided:
    1. Text Files (ASCII): The content is the data that humans can directly read, such as numbers and letters.
    2. Binary: the executable file (scripts, text-type batch processing file is not counted) in Linux is in this format.
    3. Data Files: Some programs read files in specific formats during operation. Files in specific formats can be called data files ). for example, when a user logs on to Linux, the login data is recorded in the/var/log/wtmp file, which is a data file, he can read it through the last command! But when cat is used, garbled characters are read because it is a special format file.
  • Directory ):
  • Link ):
    1. Hard Link (entity Link, Hard Link or actual Link ):

      First, each file occupies one inode, and the content of the file is directed by the inode record. to read the file, you must point to the correct inode number through the file name recorded in the directory to read the file.

      That is to say, the file name is only related to the directory, but the file content is related to inode. to put it simply, hard link only adds a link between a file name and an inode number in a directory. multiple Document Names correspond to the same inode number.

      For example, assume that my system has a/root/crontab object link of/etc/crontab, that is, these two files are linked to the same inode, naturally, all the information related to these two file names will be identical (except for the file name ). the actual situation can be as follows:

      We can find that the two files are connected to the inode number 1912701, because the two "file names" are actually the same "file 』! And you will also find that the second field is changed from the original 1 to 2! The field is called "Link". The meaning of this field is: "How many file names are linked to this inode number. if the correct data is read, the image is similar to the following:

      Note:

      1. You can find two different file names through the inode block specified by inode in the directory 1 or 2. No matter which file name you use, you can refer to real's inode to read the final data!
      2. If you delete any file name, inode and block still exist! At this time, you can read the correct file data through another "file name!
      3. No matter which file name you use for editing, the final result will be written to the same inode and block, so data can be modified!

      Requirements:

      1. Cannot span Filesystem
      2. Cannot link directory.
    2. Symbolic Link (Symbolic Link, or shortcut)

      Compared with hard link, Symbolic link is much easier to understand. Basically, Symbolic link is used to create an independent file, this file will let the data read the file name pointing to the file linked to it! Because the source file is only used as a pointing action, after the source file is deleted, the symbolic link file will "cannot open" and will always say "cannot open a file !』. The original file name cannot be found!

      For example, create a symbolic link file to link to/etc/crontab:

      From the results in the above table, we can know that two files point to different inode numbers. Of course, two independent files exist! The important content of the link file is that it will write the "file name" of the target file. You can find out why the size of the link file in the above table is 12 bytes? The file name "/etc/crontab" on the right of the arrow (-->) has 12 English letters in total. Each English occupies 1 byes, so the file size is 12 bytes!

      We will explain the preceding descriptions as follows:

      Inode 1 reads only the file name to the link file. inode of the target file is obtained based on the Link name to the correct directory, and the correct data can be read. you can find that if the target file (/etc/crontab) is deleted, the entire process will fail, therefore, the link file cannot be read!

      Note that the Symbolic Link and Windows shortcut can be assigned an equal sign, and the files created by Symbolic link are independent new files, so it will take up inode and block!

  • Device: some files related to the system perimeter and storage are usually under the/dev directory! There are two types:
    1. Block device: it refers to some interface devices that store data to provide random access to the system. For example, hard disks and floppy disks are the same! You can randomly read and write data in different blocks of the hard disk. This device is a group of devices! You can check/dev/sda and find that the first attribute is [B!
    2. Character (character) Device File: it is an interface device for some serial ports, such as the keyboard and mouse! These devices feature "one-time reading" and cannot cut the output. For example, you cannot let the mouse "jump" to another screen, but "slide" to another place! The first attribute is [c].
  • Data interface file (sockets): Since it is called a data interface file, take it for granted that this type of file is usually used for network data acceptance. we can start a program to listen to the requirements of the client, and the client can communicate data through this socket. the first attribute is [s], which is most often seen in the/var/run directory.
  • Data transmission file (FIFO, pipe): FIFO is also a special file type, which aims to solve the problem of simultaneous access to a file by multiple programs. FIFO is the abbreviation of first-in-first-out. the first attribute is [p].
Linux File Extension

Basically, the file name on the Linux system really only helps you understand the possible usage of the file. The actual execution still requires the permission specification! But whether the execution is successful depends on the content of the file.

Even so, we still want to know what the file is by using the extension. Therefore, we usually use an appropriate extension to indicate the type of the file. there are several common extensions:

  • *. Sh: a script or a batch processing file (scripts). Because the batch processing file is written in shell, the extension is compiled into. sh;
  • * Z ,*. tar, * .tar.gz ,*. zip ,*. tgz: compressed file. this is because the compression software is gunzip, tar, and so on. Because of the different compression software, the related extension is used!
  • *. Html, *. php: webpage-related files, which represent the HTML syntax and PHP syntax respectively! The. html file can be directly opened in a web browser. For the. php file, you can browse it on the server through the client browser to obtain the webpage result after calculation!

Linux File length limit

In Linux, when the preset Ext2/Ext3 file system is usedThe length of the file name is limited:

  • A single file or directory can contain a maximum of 255 characters;
  • The full path name and directory (/) are 4096 characters in length.

Linux File Name restrictions:

Since Linux has some command operation relationships under the text interface, it is recommended that you avoid special characters when setting the file name under Linux! For example:

*? > <;&! [] | \'"'(){}

These symbols have special meanings under the text interface! In addition, when the file name starts with the decimal point ".", it indicates that this file is "hidden! At the same time, the options such as-option are often used in command issuing, so you 'd better avoid naming the beginning of the file name with-or +!


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.