⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch01_23.htm

📁 the unix power tools
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<HTML><!--Distributed by F --><HEAD><TITLE>[Chapter 1] 1.23 File Access Permissions </TITLE><METANAME="DC.title"CONTENT="UNIX Power Tools"><METANAME="DC.creator"CONTENT="Jerry Peek, Tim O'Reilly &amp; Mike Loukides"><METANAME="DC.publisher"CONTENT="O'Reilly &amp; Associates, Inc."><METANAME="DC.date"CONTENT="1998-08-04T21:31:28Z"><METANAME="DC.type"CONTENT="Text.Monograph"><METANAME="DC.format"CONTENT="text/html"SCHEME="MIME"><METANAME="DC.source"CONTENT="1-56592-260-3"SCHEME="ISBN"><METANAME="DC.language"CONTENT="en-US"><METANAME="generator"CONTENT="Jade 1.1/O'Reilly DocBook 3.0 to HTML 4.0"><LINKREV="made"HREF="mailto:online-books@oreilly.com"TITLE="Online Books Comments"><LINKREL="up"HREF="ch01_01.htm"TITLE="1. Introduction"><LINKREL="prev"HREF="ch01_22.htm"TITLE="1.22 How UNIX Keeps Track of Files: Inodes "><LINKREL="next"HREF="ch01_24.htm"TITLE="1.24 The Superuser (Root) "></HEAD><BODYBGCOLOR="#FFFFFF"TEXT="#000000"><DIVCLASS="htmlnav"><H1><IMGSRC="gifs/smbanner.gif"ALT="UNIX Power Tools"USEMAP="#srchmap"BORDER="0"></H1><MAPNAME="srchmap"><AREASHAPE="RECT"COORDS="0,0,466,58"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="467,0,514,18"HREF="jobjects/fsearch.htm"ALT="Search this book"></MAP><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch01_22.htm"TITLE="1.22 How UNIX Keeps Track of Files: Inodes "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 1.22 How UNIX Keeps Track of Files: Inodes "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><B><FONTFACE="ARIEL,HELVETICA,HELV,SANSERIF"SIZE="-1">Chapter 1<BR>Introduction</FONT></B></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch01_24.htm"TITLE="1.24 The Superuser (Root) "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 1.24 The Superuser (Root) "BORDER="0"></A></TD></TR></TABLE>&nbsp;<HRALIGN="LEFT"WIDTH="515"TITLE="footer"></DIV><DIVCLASS="SECT1"><H2CLASS="sect1"><ACLASS="title"NAME="UPT-ART-1026">1.23 File Access Permissions </A></H2><PCLASS="para"><ACLASS="indexterm"NAME="UPT-ART-1026-IX-FILES-ACCESS-PERMISSIONS"></A><ACLASS="indexterm"NAME="UPT-ART-1026-IX-PERMISSIONS"></A><ACLASS="indexterm"NAME="UPT-ART-1026-IX-ACCESS-PERMISSIONS"></A>Under UNIX, access to files is based on the concept of users andgroups.</P><PCLASS="para"><ACLASS="indexterm"NAME="UPT-ART-1026-IX-USER-IDS-UIDS-FILE-ACCESS"></A><ACLASS="indexterm"NAME="AUTOID-2113"></A>Every &quot;user&quot; on a system has a unique account with a unique login name and aunique<SPANCLASS="link">UID (<ACLASS="linkend"HREF="ch38_03.htm"TITLE="Managing Processes: Overall Concepts ">38.3</A>)</SPAN>(user ID number).It is possible, and sometimes convenient, tocreate accounts that are shared by groups of people. For example, in atransaction processing application, all of the order-entry personnelmight be assigned a common login name (as far as UNIX is concerned,they only count as one user). In a research and developmentenvironment, certain administrative operations might be easier ifmembers of a team shared the same account, in addition to their ownaccounts. However, in most situations each person using the systemhas one and only one user ID, and vice versa.</P><PCLASS="para">Every user may be a member of one or more &quot;groups.&quot;[3]<ACLASS="indexterm"NAME="AUTOID-2121"></A><ACLASS="indexterm"NAME="AUTOID-2123"></A><ACLASS="indexterm"NAME="AUTOID-2125"></A>The user'sentry in the master password file(<SPANCLASS="link"><EMCLASS="emphasis">/etc/passwd</EM> (<ACLASS="linkend"HREF="ch36_03.htm"TITLE="Changing the Field Delimiter ">36.3</A>)</SPAN>)defines his&quot;primary group membership.&quot;The<SPANCLASS="link"><EMCLASS="emphasis">/etc/group</EM> (<ACLASS="linkend"HREF="ch22_13.htm"TITLE="Groups and Group Ownership ">22.13</A>)</SPAN>file defines thegroups that are available and can also assign other users to thesegroups as needed. For example, I am a member of three groups: <EMCLASS="emphasis">staff</EM>,<EMCLASS="emphasis">editors</EM>, and <EMCLASS="emphasis">research</EM>. My primary group is <EMCLASS="emphasis">staff</EM>;the <EMCLASS="emphasis">group</EM> file says that I am also a member of the <EMCLASS="emphasis">editors</EM>and <EMCLASS="emphasis">research</EM> groups. We call <EMCLASS="emphasis">editors</EM> and <EMCLASS="emphasis">research</EM>my &quot;secondary groups.&quot; The system administrator is responsible formaintaining the <EMCLASS="emphasis">group</EM> and <EMCLASS="emphasis">passwd</EM> files. You don't need toworry about them unless you're administering your own system.</P><BLOCKQUOTECLASS="footnote"><PCLASS="para">[3] In Berkeley and other newer UNIX systems, users have the access privilegesof all groups they belong to, all at the same time.In other UNIX systems, you use a command like <EMCLASS="emphasis">newgrp</EM> to changethe group you currently belong to.</P></BLOCKQUOTE><PCLASS="para">Every file belongs to one user and one group. When a file is firstcreated, its owner is the user who created it; its group is<SPANCLASS="link"> the user's primary group or the group of the directory it's created in . (<ACLASS="linkend"HREF="ch22_05.htm"TITLE="Group Permissions in a Directory with the setgid Bit ">22.5</A>, <ACLASS="linkend"HREF="ch22_13.htm"TITLE="Groups and Group Ownership ">22.13</A>)</SPAN>For example, all files I create are owned by the user<EMCLASS="emphasis">mikel</EM> and the group <EMCLASS="emphasis">staff</EM>. As the file's owner, I am allowed touse the<ACLASS="indexterm"NAME="AUTOID-2146"></A><EMCLASS="emphasis">chgrp</EM> commandto change the file'sgroup.On filesystems that don't have<SPANCLASS="link">quotas (<ACLASS="linkend"HREF="ch24_17.htm"TITLE="Disk Quotas ">24.17</A>)</SPAN>,I can also use the<ACLASS="indexterm"NAME="AUTOID-2150"></A><EMCLASS="emphasis">chown</EM> commandto change the file's owner.(To change ownership on systems with quotas, see article<ACLASS="xref"HREF="ch22_21.htm"TITLE="How to Change File Ownership Without chown">22.21</A>.)For example, to change the file <EMCLASS="emphasis">data</EM> so that itis owned by the user <EMCLASS="emphasis">george</EM> and the group <EMCLASS="emphasis">others</EM>, I givethe commands:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">% <CODECLASS="userinput"><B>chgrp others data</B></CODE>% <CODECLASS="userinput"><B>chown george data</B></CODE></PRE></BLOCKQUOTE></P><PCLASS="para">If you need to change both owner and group, change the group first!You won't have permission to change the group after you aren't the owner.Some versions of <EMCLASS="emphasis">chown</EM> can change both owner and group at the sametime:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">% <CODECLASS="userinput"><B>chown george.others data</B></CODE></PRE></BLOCKQUOTE></P><TABLECLASS="para.programreference"BORDER="1"><TR><THVALIGN="TOP"><ACLASS="programreference"HREF="examples/index.htm"TITLE="chown">chown</A><BR><ACLASS="programreference"HREF="examples/index.htm"TITLE="chgrp">chgrp</A><BR></TH><TDVALIGN="TOP">&#13;If you need <EMCLASS="emphasis">chown</EM> or <EMCLASS="emphasis">chgrp</EM> for some reason, the GNUversions are on the CD-ROM.</TD></TR></TABLE><PCLASS="para"><ACLASS="indexterm"NAME="UPT-ART-1026-IX-MODE-BITS"></A

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -