2011年10月17日星期一

Moncler Jackets UK Linux Learning ( 4 ) discipline files and directories ( on ) .


a discipline files and directories, users, groups, others
two, Linux files and directories permissions
1, linux document properties explain
2, fix file attribute
three , linux document extension name
four, Linux directory with
1, Filesystem Hierarchy Standard (FHS)
2, FHS directories explain
3, the directory using careful
4, which is comparable to common scattered disk case
References
a user, group, others
:. Tube users into the Linux User, Group and Others three levels. For the users themselves, the user belongs to groups, and other users.
:. root access for Linux users the highest
:. Linux using the identity and group registration file
In Linux, the user information registered in the / etc / passwd file within this, the password is is registered in the / etc / shadow file this under, Linux all the group names are recorded in / etc / group.
two, Linux files and directories permissions 1, linux document properties explain
example: under the root user to use ls to look at the document called for the property
[root @ linux ~] # ls-al total 248 drwxr- x --- 9 root root 4096 Jul 11 ​​14:58.
drwxr-xr-x 24 root root 4096 Jul 917:25.
-rw --- 1 root root 1491 Jun 25 08:53 anaconda- ks.cfg
.
:. the meaning of the above seven properties as follows:
: .1) one of the most important attributes of property rights: is divided into file types, user, group, other permissions attribute 4 10 symbols.
:. The first property on behalf of this file is ] is the file, for example, the first 5 rows on the table;
if [l] is represented as a linked file (link file);
if [b] is represented as device files for storage inside the perimeter equipment;
if [c] indicates that the device file inside the serial port equipment, such as keyboard, mouse.
:. The next attribute, three as a group, and are One, [r] on behalf of read (read), [w] representative may write (write), [x] representatives are rigorously enforce (execute):
first group as two groups as Example: If a file's attributes to as: on behalf of the file directory or file name (top of file)
234 is: a human rights (see above for the read, write, can be rigorously enforce)
567 as: the use of the same group permissions ( To read the above can be rigorously enforce)
890 as: the use of other privileges (read-only above): Note:
drwx - 3 root root 4096 Jun 25 08:35. ssh
if a directory. ssh permissions as above, is that unless the root user, other users have not access into this directory, only root has x permission. : .2) Occupy the second column indicates the node connecting the (i-node): this file with the link (link file) compared with the relationship, if a directory, then just how much with the directory catalog on.
: .3) The third column indicates the file (or directory) : .4) The fourth column indicates a group of people.
: .5) The fifth column for the file size. : .6) The sixth column is the date of filing of this file may be the most recent amendments to date, departure for the month, the date of the work. In particular, please be careful, if you are based on Traditional Chinese to hold your Linux installation, then the default language may be changed to Chinese. And because the Chinese can not reveal the type of terminal in the text above, so this column will become a strange garbled, this time, please correct look / etc/sysconfig/i18n this file inside the = en So how to fix the files? Oh! As root, use vi correction. In addition, it can use file
2, fix file attribute
chgrp: change file Group
chown: change file belongs to people
chmod: change file attributes, SUID, and so the personality
: .1 ) Change Group, chgrp
the call even if the change group's acronym to remember to change the group names will certainly be in / etc / group names which exist in the job, otherwise it will reveal the false absurd!
Example:
[root @ linux ~] # chgrp users install.log
[root @ linux ~] # ls-l
-rw-r - r - 1 root users 68495 Jun 25 08:53 install.log
[root @ linux ~] # chgrp testing install.log chgrp: invalid group name `testing '== false wrong message - can not find the occurrence of this group were ~
: .2) Change file with the person, chown
change with a person even change owner, who will certainly be using those stored in the system, but also even in the / etc / passwd This file records the use of those names with the job change.
Example:
[root @ linux ~] # chown [-R] account names file or directory
[root @ linux ~] # chown [-R] account names: Group names files or directories < br> parameters:
-R: recursive held (recursive) to continue to change, which together with the sub-directory of all files, directories
are updated as the group intended. Often used in the case of a directory changes.
model:
[root @ linux ~] # chown bin install.log
[root @ linux ~] # ls-l
-rw-r - r - 1 bin users 68495 Jun 25 08:53 install.log
[root @ linux ~] # chown root: root install.log
[root @ linux ~] # ls-l
-rw-r - r - 1 root root 68495 Jun 25 08:53 install.log
: .3) change of nine properties, chmod
file attributes this change to use the chmod call, however, there are two properties of the set of measures, parting may be able to use the number sign to hold property changes
:. digital type change file permissions
Linux file attributes have about nine, parting is owner / group / others group read / write / execute properties
The nine properties are three groups of three! Among them, we can use numbers to represent the various attributes, the attribute match table is as follows:
r: 4 w: 2 x: 1
Unity (owner / group / others) of the three attributes (r / w / x) is a necessary additive,Moncler Jackets UK, such as when the property is [-rwxrwx ---] is:
owner = rwx = 4 +2 +1 = 7 group = rwx = 4 +2 +1 = 7 others =- --= 0 +0 +0 = 0
wait so we set the property changed, even if the property is the number 770.
Example:
root @ linux ~] # chmod [-R] xyz file or directory
parameters:
xyz: even mentioned the number of types of property rights, property values ​​are rwx add c4ma.com.
-R: recursive held (recursive) to continue to change, which together with the sub-directory of all files, directories
are updated as the group intended. Often used in the case of a directory changes.
for example, if you want. bashrc file all the attributes that are open, then issued:
[root @ linux ~] # ls-al.bashrc
-rw-r - r- -1 root root 395 Jul 411:45. bashrc
[root @ linux ~] # chmod 777.bashrc
[root @ linux ~] # ls-al.bashrc
-rwxrwxrwx 1root root 395 Jul 411 : 45.bashrc
:. symbol change the file type there is a change of property rights
measures Yo! Recommendation from the previous, we can perceive, approximately nine properties on the parting is (1) user (2) group (3) others three groups it! Then we can use these u, g, o to represent three groups of properties! In addition, a fully represents all that the three groups! Then the property will be able to read and write written a r, w, x! Are even able to use the measures under the terms:
chmod u/g/0/a +(+/-/=)+( r / w / x)
Example:
root @ linux ~] # chmod u = rwx, go = rx.bashrc
# beware Oh! That u = rwx, go = rx is connected at the same time, and which had not been any space other characters!
[root @ linux ~] # ls-al.bashrc
-rwxr-xr-x 1root root 395 Jul 411:45. bashrc
I do not know if the original file attributes, and I just want purchase. bashrc This file permissions for each person can write, then I can use:
[root @ linux ~] # ls-al.bashrc
-rwxr-xr-x 1root root 395 Jul 411 : 45.bashrc
[root @ linux ~] # chmod a + w.bashrc
[root @ linux ~] # ls-al.bashrc
-rwxrwxrwx 1root root 395 Jul 411:45. bashrc < br> The case was removed without change to properties of other properties?! For example, to remove all the attributes of x, then:
[root @ linux ~] # chmod ax.bashrc
[root @ linux ~] # ls-al.bashrc
-rw-rw- rw-1 root root 395 Jul 411:45. bashrc three, linux documentation about the extension name
, Linux's file is not the so-called Files can not be rigorously enforce, with his first column on the ten attributes, and the extension were not about that relationship. This belief is not identical with the case of Windows. Under Windows, can be rigorously enforce the file extension lightly 是. Com.exe.bat, etc., and in Linux under, any property which you have x, then, for example, [-rwx-r-xr-x], which represents This file can be rigorously enforce. Four, Linux directory with
1, Filesystem Hierarchy Standard (FHS)
Linux the FHS (om / fhs /) in fact is only a specification in the root directory (/) directory under the various important what deserves to be placed kind of file it. FHS specification defines a two-out, the first layer is the / directory under each deserve to be placed on what the content of archival material, such as / etc deserve to be placed on the profile, / bin and / sbin then deserve to be put to its efforts to file, etc. and so on. The second layer is for / usr and / var directories of these two sub-directories defined. For example, / var / log to place the system registry, / usr / share placing to share materials and so on.
defined by the FHS directory hierarchy and structure. 2, FHS catalog explains:
/
root of the root (/), lightly to promote access only in the root directory under the directory, not directly to a file in / under. Root directory is the first system boot time to load the partition, thus, all files will be used during the boot process, deserve to be placed in this partition of them. For example, / etc, / bin, / dev, / lib, / sbin directories are five times deserve to be connected with the root directory at the same time, not self-reliance to become a partition
/ bin,
/ usr / bin,
/ usr / local / bin
unless / bin outside, / usr / local / bin, / usr / bin is placed on ,Moncler Jackets UK, mv, rm, mkdir, rmdir, gzip, tar, cat, cp, mount, and so important calls are placed in the directory where.
/ boot
important goal of this directory is where the Linux system time is used to open the file. Open the opportunity to use it? Yes - even the center of Linux files. The directory under the file name even if the Linux Kernel vmlinuz very important thing! And if you boot discipline program (loader) choice grub, then there is this directory / boot / grub directory this time
/ dev
on Linux systems, and peripheral equipment is any device to file patterns which exist in this directory. You all through access a file under this directory, it means access to a device
important and peripheral equipment into
(character device), such as keyboard, mouse, etc.;
storage equipment (block device), such as hard drives, CDs and so on.
/ etc
system is important to place almost all the profiles in this directory, such as personnel, account password file,Moncler Jackets UK, initiate a variety of services, file and so on. Trivial, this directory of the file attribute is the ability to access the use of those taken lightly, but only root has authority to amend. And the files in this directory are ASCII text almost archives miles. However, FHS can not be placed to promote its efforts to file in this directory Oh. Compare your important files: / etc / inittab, / etc / init.d /, / etc / modprobe.conf, / etc/X11, / etc / fstab, / etc / sysconfig / so
/ home
This is the system used by the default home directory (home directory). You add a lightly used in those accounts, the default home directory will regulate the use of those to come here. Match is important that home directory, there are two code Oh:
~: on behalf of the person reflected in the use of the home directory, and
~ dmtsai: represents dmtsai home directory!
/ lib,
/ usr / lib,
/ usr / local / lib
system will use to place the library catalog. In the course of the operation of the program may be roaring additional function parameters, and that libraries need help! These libraries will be placed here. Match is important that / lib / modules will be placed in this directory the kernel module coherent Oh!
/ lost + found
system does not normally produce false absurd, the pieces will be some of the pessimistic place in this directory, this directory will actively develop lightly now a top-level directory partition. For example, you install a hard disk in the / disk in, it will be active in this directory produce such a directory / disk / lost + found
/ mnt
/ media
This is a floppy disk with The default mount point where the disc; lightly floppy hanging in the / mnt / floppy, the CD while hanging in the / mnt / cdrom, although you need not be it! Where you happy, easy to find a place to mount can it! In addition, plans are now out of another / media directory too! And / mnt somewhat similar friends ~
/ opt which is to host the display of additional software installation directory. For example, FC4 using the Fedora community developed software, in case you want to own today to install new KDE desktop software, then, can the software be installed on the meaning of this directory.
/ proc
the directory itself is a Because the directory in which materials are in memory, which itself does not occupy any disk space ah! Compare your important files such as: / proc / cpuinfo, / proc / dma, / proc / interrupts, / proc / ioports, / proc / net / * and so on.
/ root
system management staff (root) home directory. Of which on here, because as we mentioned, the system first to be loaded on boot partition as /, and we want / root with / on the uniform block partition above the rules.
/ sbin,
/ usr / sbin,
/ usr / local / sbin
placed some of the systems management staff will take to rigorously enforce the call, for example: fdisk, mke2fs, fsck, mkswap, mount and so on. And / bin are not the same place, these and other systems to the root directory is used for discipline. However, its efforts to file under this directory, or allow the use of those lightly used For example, WWW server, the web material must be able to be placed in / srv / www inside.
/ tmp
this way, may be trivial to use the process of being rigorously enforce temporary place to put files. This directory is anyone able to access, so you must regularly clean up. Of course, an important material can not be placed in this directory.
/ usr
the second layer from the FHS specification content in / usr This directory, including the system's critical programs, files necessary for the graphical interface, additional library, the local side of the self-installation software, and to share directories and files, etc., are able to perceive them in this directory. In fact, he was somewhat like a Windows monopoly system in which the In this important sub-directory under the directory are:
/ usr / bin, / usr / sbin: lightly used by identity management and staff to rigorously enforce the system to place the file directory;
/ usr / include: c / c + +, etc. programming language header (header) and include files (include) placed at, when we measure tarball (*. tar.gz measures to install software) to install some of the material, it will take advantage of the many include files inside Oh! ;
/ Usr / lib: the library of files using software www.kaiban.org place catalog;
/ usr / local: the local side to place their own pre-installed software catalog. Practical now in the / opt directory. Later on you have installed Linux, about all the features you have it all, but software can always be upgraded, for example, you want to upgrade your proxy service, then lightly place the software pre-installed even in the / usr / local (local is To a promotion of the matter, will be lightly birds brother was later placed in the installation of the software up here, because the ease of discipline Yo;
/ usr / share: share the file be placed in the directory, for example, under the two directories:
/ usr / share / doc: to put in place systems to interpret the file, for example, you install grub, then look them in the directory below, the explanation can be found grub files! It is convenient!
/ usr / share / man: manpage files file directory; What is that? Oh! Even when you use man, will go to the query path it! For example, man ls you use this call, they will find out / usr/share/man/man1/ls.1.gz this explanation of the contents of the file!
/ usr / src: Linux system coherent place code directory, for example / usr / src / linux as the central source!
/ usr/X11R6: X Window System within the system files required for almost all of its efforts to put it!
/ var
this directory is also very important, but also the FHS specification of the second layer of directory contents. He placed a significant journey for the system applied in order, the norm of the change in place of the directory file. For example, such as cache files (cache) may be changed at any time of the log file (log file) are placed in this directory. In addition, some software will be applied in order to write the journey of the material library file, library materials, such as MySQL, are also written in this directory! It is very important! His important directories under there:
/ var / cache: program files in the course of some of the temporary files;
/ var / lib: the program itself with its efforts in the process, must use the material to be placed in the directory file , for example, locate the materials, library materials and MySQL database system and the engine rpm, etc., are written in this directory.
/ var / log: Log files placed in the directory. Is very important to ah! For example, / var / log / messages log file of all mains, even a file!
/ var / lock: write some devices have sequential nature of the personality, such as tab (tape), at the moment, for fear of being disturbed and destroyed others, the action is in operation, and therefore, the device will lock ( lock) up to ensure that the device can only be used by a process sheet ah!
/ var / run: Some programs may be the service started, the PID will they be placed in this directory Oh!
/ var / spool: some queue material storage areas. Example, the hosts receive the email, will be placed in / var / spool / mail which, if temporarily unable to pronounce the letter will be placed into / var / spool / mqueue directory, the use of those Task Scheduler (cron ) is placed in the / var / spool / cron three, catalog using careful
: .1) promote root partition can not be parting with the directory
/ etc /, / sbin /, / bin /, / dev / and / lib / these directories,
because our Linux system at boot time, set the start at center fashion, it will only load a partition, that even if the /.
: .2) to promote good self-reliance as a single partition of the directory catalog it is because some
safe sex and specific functionality, and a desire to become self-reliant own partition, for example: / home, / usr, / var , / tmp, and so on.
: .3) systems use personal home directory in / home inside, this directory is likely to be the most frequent use of one of the directories. In addition, to a more balanced allocation of resources, we may limit his desire for everyone to take advantage of the maximum total amount of hard disk (quota), in this context, you will certainly want to / home out of self-reliance, and this partition can be good larger
:. / usr are some of the installation directory, but also to self-reliance out of
:. there is / var /, this directory as registered with most commonly used material, but also eager to 4 out of self-reliance This is comparable to a common disk distribution case:
/ root directory to allocate about 1 GB or less;
/ boot 50 MB may be able to, because the boot files are not large;
/ var on required at least 1GB or more, because your mail, proxy default storage areas are in this directory
/ home and / usr is the largest lightly, because you have the materials are installed in / usr / them, and user material is placed in the / home one, so we will promote you to be taken lightly by the rest of the disk space allocated to the balance of these two directories that! But also do not set it! / Usr may be on to a 10G to a number of others gave the ~ / home
this article is to learn Linux, notes, to thank the original author: Bird Brother (vbird, vbird@mail.vbird.idv.tw), linux . vbird.org References:
[1] original: linux file attributes and directory with linux.vbird.org/linux_basic/0210filepermission.php
[2] Ricard Chen (ricard_chen@yahoo.com), resolution in Linux The VFS file system mechanism, om / developerworks / cn / linux / l-vfs / index.html
we will benefit greatly from a formal code review (codeinspection) code is self-improvement and expansion of skills most merit one, < br>

没有评论:

发表评论