Archive system, permission concept and practice

xiaoxiao2021-03-06  17

Archive system, permission concept and practice

I. Linux archives system:

In Linux, anything, including peripheral hardware, is considered a file. (Keep in mind)

Because the number of files is a lot, there must be a good set of archive systems to manage.

Note: Linux supports a lot of archive systems! Such as MSDOS, VFAT, Minix, EXT, EXT2 .... and so on. Currently in EXT2 (Second Extended File System) as the main archive system.

1. Linux archives system, using hierarchical tree directory structure.

The uppermost layer is the root directory /, and the next layer contains other directories.

In general, there are these directories:

/ USR Application Installation Location / ETC Setting Base / LIB Function Library / VAR Ticket / TMP Temporary Directory / BIN User Program / SBIN Administrator program directory / MNT archive system hanging point / DEV Equipment Document Organization / Home Home Directory Base Camp, you can build your own directory of your account, that is, all accounts place web space / Lost Found Lost Archive Place

(Under the catalog, there can be other sub-directorys, according to this ....)

Each directory can be selected on a different split area in a mount (you should remember that some splits do it when we install Redhat,) For safety, experienced system managers, usually practice.

These catalogs, because of historical reasons, gradually, with specific storage content, but the UNIX systems of each home have different practices, thereby causing their respective disorders, undoubtedly, this will bring the system management Invenation, there is currently, there is a set of naming and storage standard File System Standard (FSSTND), Redhat Linux is an interested in this standard. If you are interested in this standard, you can go to http: // Www.pathname.com/fhs/.

2. The file of Linux consists of a series of Data Block.

Block's size, decide when installing the archive system, usually 512 Bytes multiple, such as 512, 1024, 2048, 4096 Bytes.

RedHat is 4096 Bytes, and the general purpose is not required. If your host is intended to be a BBS station, it usually sets Block 1024 Bytes, because the Size of the letter file is usually not big, so, You can save a lot of hard drive space.

3. Linux Care Inode (INDEX Node) is used as a block index to access information.

The so-called inode is a separate storage area (128 bytes) to describe information such as permission attributes, file size and archive information storage block (Data Block). Each file is established, the system is A exclusive inode is configured, which contains a unique inode number (INODE number) representative of the file.

Linux's archive system, that is, based on the inode number, to reject the file to access the information of the file.

How to learn the INODE number of the file?

You can see it with ls -i. (-I is the meaning of inode)

18073 Bin 2 Home 2 OLS3 2 USR

20081 Boot 41 Home2 1 Proc 2 Var

42 Config 2010 LIB 16066 ROOT

10041 DEV 11 Lost Found 18074 Sbin

12049 ETC 6026 MNT 14057 TMP

4. File type.

Common files have the following:

Text file (ASCII) binary (binary) directory symbol connectivity device file

Among them, the device file can be divided into two: block (Block) Equipment Field (CHARACTER) device file

The so-called block device file is stored in the surrounding area, such as the split area / DEV / HDA1, such as the soft disc and the hard disk.

The character device file is a periphery that can read the sequence font, such as Keyboard, Serial Port, Terminal, etc.

The device file is placed in / dev this directory.

So, how do you determine that a file belongs to? There are two methods:

LS -L -RW-RW-R - 1 root root 135 APR 11 12:01 config

-rwxr-xr-x 1 root root 58156 May 8 1998 Mail

DRWXR-XR-X 4 root root 2048 AUG 31 1998 LIB

LRWXRWXRWX 1 root root 5 Feb 25 16:28 Home2-> / OLS3

BRW-RW-R - 1 Root Floppy 2, 0 May 6 1998 FD0

BRW-RW ---- 1 Root Disk 3, 1 May 6 1998 HDA1

CRW-RW ---- 1 Root UUCP 5, 64 May 6 1998 Cua0

CRW ------- 1 root root 4, 0 May 6 1998 TTY0

With File Directive, such as a file file name or file *

5. Naming of the file.

Linux files can be named with AZ 0-9. _ - and other symbols, up to 256 words. (DOS has 8.3 file format restrictions, and current Win95 / 98 VFAT long-file name format, I believe is the imitation of the Unix system The method can be used to distinguish the use of the file name, such as: Ols3GBK.PL, Test.c, myword.txt, squid.doc, httpd.conf, the name of the file, and the type of the file, There is no direct connection, in other words, you can put a text file, named runit.exe, but does not mean it is an execut file. In Linux, the file can be executed, only with the file's permissions attribute, and The secondary file has no absolute correlation.

Due to the ability of Linux's long file name, the name of many files seems very long, which makes people accustomed to the DOS / WIN platform, very uncomfortable, especially those who do not top the word, even more Very complained.

Therefore, you must break through this layer of mental obstacles! ^ _ ^

6. Directory (it is also one of the files)

The existence of the directory is for classification, convenient management. The directory contains files and subdirectories.

In Linux, please keep in mind two points:

Represents this catalog itself

.. Represents a directory of the previous layer

How to learn, those file names, in fact itself is a directory? Try the ls -la.

Hold

File

Case

Size file size recently revised

Class file authority number owner group (Byte unit) date and time file name

DRWXR-XR-X 14 root root 1024 JUL 21 21:31.

DRWXR-XR-X 17 root root 1024 APR 11 12:01..

DRWXR-XR-X 8 82 82 1024 Feb 25 19:23 Apache

-rw-r - r - 1 root root 1335460 Feb 25 17:45 Apache_1_3_4.tar.gz

DRWXR-XR-X 6 root root 1024 AUG 31 1998 ftpdrwxr-xr-x 5 root root 1024 AUG 31 1998 httpd

DRWX ------ 2 James James 1024 Apr 23 06:47 James

DRWXR-XR-X 2 root root 12288 aug 31 1998 Lost Found

DRWXR-XR-X 2 MSQL Nobody 1024 DEC 28 1998 MSQL

DRWXR-XR-X 28 OLS3 OLS3 2048 JUL 19 21:38 OLS3

DRWXR-XR-X 3 1022 Nobody 1024 Jan 25 23:40 OLS3CGI

DRWXRWXR-X 3 Perl Ols3 1024 Feb 2 07:11 Perl

-rw ------- 1 root root 2097152 jul 21 18:39 quota.group

-rw ------- 1 root root 1278656 jul 21 18:39 quota.user

Drwxrwxr-x 2 root nobody 1024 May 11 1998 Samba

DRWXR-XR-X 3 Apache NoBody 1024 Feb 25 16:58 Temp

DRWXRWXR-X 2 Webadm Nobody 1024 Mar 14 16:34 WebAdm

The file permission begins with the D person, which is a directory. If it is one-mark, it is an ordinary file.

If the file is a normal file, the number of files is 1. If it is a directory, at least 2 (ie., ..)

How do you know how to have a current location (PWD: Print Name of current / Working Directory)?

Archive owners -2 file * | grep directory | wc -l

7. Symbol connection. (Symbolic Link)

The so-called symbol connection is the meaning of the alias (fresher) of this file.

There are two symbols in Linux:

Hard Link soft connection (Soft Link)

The so-called hard connecting file is a copy of a file. Its file content is completely exactly the same as the original file. When the original file content changes, the hard connecting file is also the same as the work. But if the original file is deleted, the Hard Link file is still Will exist.

The soft link is an alias of the file that is used to connect to the original file.

Whether it is the kind, access symbol connecting, is equal to the original file.

Under the bottom is an example of a symbol connection:

-rw-rw-r - 2 root root 20 jul 21 22:00 Hard-link

LRWXRWXRWX 1 root root 11 jul 21 21:59 Soft-link -> Source-file

-rw-rw-r - 2 root root 20 jul 21 22:00 Source-file

The symbolic link has a very large purpose, this is the other platform such as DOS / WIN can't match.

For example: a certain directory space is insufficient, then I can hang the new hard drive space, using a symbolic connection, while maintaining the original directory structure unchanged.

However, it is too convenient, it is also a fatal injury, another Linux Distribution: Slackware, early Tool is too disordered, for people's fourth disease.

How to make Symbolic Link Files?

Methods as below:

LN [-sf] Source Target Example:

Ln Source-file hard-link

LN -SF Source-File Soft-Link

s indicates that Soft Link is meaning, and f, if there is a name file, it covers it.

8. Hidden files.

Linux also has a hidden file mechanism! As long as the file is named. When you look at it, you will not be displayed, (unless you use ls -a), we usually hide the file, take it as a program Initialization setting file, or as a special function use (such as .forward, .rhosts)

As follows:

[root @ ols3 / root] # ls -la

Total 54

DRWXR-XR-X 9 root root 1024 JUL 18 22:53.

DRWXR-XR-X 17 root root 1024 APR 11 12:01..

-rw-r - r - 1 root root 548 jul 18 22:56 .fvwm2-errors

-rw-r - r - 1 root root 1126 AUG 24 1995 .xdefaults

-rw-r - r - 1 root root 11974 jul 21 22:19 .bash_history

-rw-r - r - 1 root root 24 JUL 14 1994.bash_logout

-rw-r - r - 1 root root 253 APR 11 12:07 .bash_profile

-rw-r - r - 1 root root 176 aug 24 1995.bashrc

-rw-r - r - 1 root root 180 Mar 4 1996 .cshrc

DRWX ------ 2 root root 1024 Sep 1 1998 .lm

Drwx ------ 2 root root 1024 aug 31 1998 .gnome

Drwx ------ 2 Root Root 1024 AUG 31 1998 .Gnome_private

-rw ------- 1 root root 2222 mar 14 16:42 .MYSQL_HISTORY

DRWX ------ 4 root root 1024 APR 11 11:19 .Netscape

-rw-r - r - 1 root root 166 Mar 4 1996.tcshrc

DRWX ------ 2 Root Root 1024 Sep 1 1998 Mail

-rw-r - r - 1 root root 353 JUL 18 22:53 xrootenv.0

DRWXR-XR-X 2 root root 3072 APR 11 11:39 CHINESE

- WXRW - WT 1 Root Root 22 APR 11 11:28 Chinesech_profile

-rw-r - r - 1 root root 165 APR 11 11:28 Chinesekcfont

-rw-r - r - 1 root root 11320 JUL 15 19:56 debug

9. Archive path.

Linux's file path can be divided into two representations, but there is no disk code to code this stuff!

Absolute path relative path

The so-called absolute path is to be represented by the root directory, such as /Home/ols3/www/index.html, is the actual path location.

It can also be said that all file path positions are absolute.

So, the so-called relative path is the beginning without / this root directory symbol.

If a path is a relative path, then it means that the current directory begins, so the system will automatically help you add the current directory location in front.

For example: SRC / Linux / Arch / I386 / Linux.c (if PWD is / usr)

That is, the actual path location is: /usr/src/linux/arch/i386/linux.c

II. Concept of archive authority:

For Linux archives system, I believe that you already have a preliminary understanding. Next, you must know Linux file permission concept.

Because Linux is a multi-worker OS, the archive system must have a strict protection measures to avoid, because intentional or unintentional people are destroyed, causing confusion and loss.

Linux uses file permissions to achieve the above purposes.

A system administrator should have the correct and clear file permission concept to make the system work properly and avoid the file damage, and prevent the gains and small invasion. (The hacker is not the intention of Hacker, please name!)

1. Linux divides the file into three identities, four privileges:

Three identities are:

u: ourselves G: People in the same group (Group) o: Other people (other)

And A is all the people represent all.

There are four possible privileges for each identity:

R: Read) W: Writing rights (WRITE) X: Execute (Execute)

And: (The above three permissions are used up, less use less, please try not to use, unless you really know what you are doing ?!)

S: SET User ID / Set Group ID and T: Sticky Bit (referred to as SST Mode) 4000: SET User ID, 2000 Set Group ID, 1000 Set Sticky Bit

Linux represents the permissions of the file with 9 Bits, as shown below:

- - - - - Rwxrwxrwx owner's homework

The left side represents the type of file, it may be:

- D l b C

Other 9 locations, each of which form a group, from left to right, represents the authority of owners, the same group, and others, respectively.

Three locations of each group, by left to right: read, write, execute permissions, if only one line is only one line, it means that it does not have this permission.

In addition, we also use numbers to represent different permissions:

Read: 4 Write: 2 Execution: 1

If a certain file, the permissions it owns is RWX, then we add the size of the numbers represented by 4 2 1 = 7

The following is a possible combination:

--- 0 - X1-W-2R - 4-WX2 1 = 3R-X4 1 = 5rw-4 2 = 6rwx7

Because all possible combinations, its permissions size is only 0 ~ 7,

So, we also treat it as an eight-in-one digital system, and often use numbers to represent the level of permissions of a file.

example:

Hold

File

Case

Size file size recently revised

Class file authority number owner group (Byte unit) date and time file name

DRWXR-XR-X 14 root root 1024 JUL 21 21:31.

DRWXR-XR-X 17 root root 1024 APR 11 12:01..

DRWXR-XR-X 8 82 82 1024 Feb 25 19:23 Apache

-rw-r - r - 1 root root 1335460 Feb 25 17:45 Apache_1_3_4.tar.gz

DRWXR-XR-X 6 root root 1024 AUG 31 1998 ftpdrwxr-xr-x 5 root root 1024 AUG 31 1998 httpd

DRWX ------ 2 James James 1024 Apr 23 06:47 James

DRWXR-XR-X 2 root root 12288 aug 31 1998 Lost Found

DRWXR-XR-X 2 MSQL Nobody 1024 DEC 28 1998 MSQL

DRWXR-XR-X 28 OLS3 OLS3 2048 JUL 19 21:38 OLS3

DRWXR-XR-X 3 1022 Nobody 1024 Jan 25 23:40 OLS3CGI

DRWXRWXR-X 3 Perl Ols3 1024 Feb 2 07:11 Perl

-rw ------- 1 root root 2097152 jul 21 18:39 quota.group

-rw ------- 1 root root 1278656 jul 21 18:39 quota.user

-RWXR-XR-x 1 root root 656 JUL 12 01:39 OLS3GBK.PL

^^^^^^^^^^

Drwxrwxr-x 2 root nobody 1024 May 11 1998 Samba

DRWXR-XR-X 3 Apache NoBody 1024 Feb 25 16:58 Temp

DRWXRWXR-X 2 Webadm Nobody 1024 Mar 14 16:34 WebAdm

The above picture is an example:

Ols3GBK.pl is an ordinary file that owns ROOT, group is root, the permission of this file is:

Has: readable, writable, can perform the same group: readable, executable (but not writable) other people: readable, executable (but not writable)

Use an eight-in number to indicate that this file authority is: 755

Trial: What is the corresponding eight-carry number of permissions?

RWX - X - X R - R - R - RW-RW-RW - --X - X - X RWXRWXRWX R-XR-XR-X

Qualification: Why is the following eight-in-one digit?

611 755 666 544 733 634

2. Methods of changing permissions.

There are two ways to change file permissions:

Octa-induced digital mode symbol mode

The instructions used are: chmod (Change Mode: Change The Access Permissions Of Files)

Methods as below:

CHMOD permission file / directory

example:

Chmod 666 myfile chmod 777 myfile chmod 755 myfile chmod 111 myfile

The above is the eight-in-line digital mode

chmod u x myfile chmod u-x myfile chmod ug x myfile chmod g-x myfile chmod o x myfile chmod o-x myfile chmod a x myfile chmod a-x myfile chmod a = x myfile chmod u = wr myfile chmod go = rx myfile

The above is the symbol mode.

Table Add this kind of authority

- Table removes this kind of authority

= Table setting made this kind of authority

3. Permissions of the directory.

The permissions, concepts and trials of the catalog, the permissions of the file, but the meaning of it is large.

With the "executable" permissions, the file is easy to understand if the file is set to executable, but if the directory is set to executable, can the directory really executable? ?: -Q is of course not.

Linux for the permissions of the directory, another view:

r can list the file name in the directory, that is, the LS is in this directory, can be filed, change the name, and build a new file X can enter the directory (important concept, large)

If there is a certain directory, there are many files and subdirects, and if there is any way to change all file permissions at a time?

Of course.

CHMOD -R Permissions Directory Name

Where -R indicates that Recursively Change Permissions Of Directories and their Contents, it is intended to return all the files and directories under them.

4. Change the owner (OWNER) or group of the file (Group)

Usually this only root level user has this power. (Otherwise, the world is chaotic! However, some UUIX Clone has a restricted practice)

Methods as below:

Chown [-r] Owner: Group Archive / Directory

example:

Chown -r 3slo: Hacker / Home / OLS3

5. Umask (file security filter).

What is umask? Umask is a mask value of file permissions when newly established a file or directory.

Its mode of operation is: minus the system's preset value of the system is the permissions of the last file / directory.

In general, the preset value of the new archive is 666. The preset value of the new directory is 777. If umask is set to 022,

Then when a new file is established, its real permission should be 666-022 = 644

When the new directory is established, its permissions are 777-022 = 755

With umask, new files and directories will be safe.

How do I know how much is the current umask value?

UMASK

III. Practice:

LS CD ~ File Cat Head Tail More Less PWD GREP WC VI MAN CLEAR CP MV RM Find Which Locate Whereeis LN MKDIR RMDIR CHMOD Chown Umask ID Whoami Mount Umount MKFS MKE2FS FDFORMAT DD

转载请注明原文地址:https://www.9cbs.com/read-42234.html

New Post(0)