File: node17.html

package info (click to toggle)
rutebook 1.0-1
  • links: PTS
  • area: non-free
  • in suites: sarge
  • size: 9,476 kB
  • ctags: 1,112
  • sloc: makefile: 47
file content (401 lines) | stat: -rw-r--r-- 15,414 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

<!--Converted with LaTeX2HTML 99.2beta8 (1.46)
original version by:  Nikos Drakos, CBLU, University of Leeds
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>14. Permission and Modification Times</TITLE>
<META NAME="description" CONTENT="14. Permission and Modification Times">
<META NAME="keywords" CONTENT="rute">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="LaTeX2HTML v99.2beta8">
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">

<LINK REL="STYLESHEET" HREF="rute.css">

<LINK REL="next" HREF="node18.html">
<LINK REL="previous" HREF="node16.html">
<LINK REL="up" HREF="rute.html">
<LINK REL="next" HREF="node18.html">
</HEAD>

<BODY BGCOLOR=#FFFFFF >
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
<TR><TD align=left bgcolor="#000000">
<FONT COLOR=white>
&nbsp;<A HREF="http://www.icon.co.za/~psheer/rute-purchase.html"><FONT COLOR=white>Purchase</FONT></A>&nbsp;
</FONT>
</TD><TD align=center bgcolor="#000000">
<FONT COLOR=white>
Copyright&nbsp;&#169;&nbsp;2002&nbsp;Paul Sheer. <A HREF="copying.html"><FONT COLOR=white>Click here for copying permissions.</FONT></A>
</FONT>
</TD><TD align=right bgcolor="#000000">
<FONT COLOR=white>
&nbsp;<A HREF="http://www.icon.co.za/~psheer/rute-home.html"><FONT COLOR=white>Home</FONT></A>&nbsp;
</FONT>
</TD></TR>
<TR><TD colspan=2 align=left bgcolor="#ECEBF4">
<IMG SRC="va-btn-small-light-60.png">
</TD><TD align=right bgcolor="#ECEBF4">
<IMG SRC="sflogo2-steel-60.png">
</TD></TR>
</TABLE><BR>

<!--Navigation Panel-->
<A NAME="tex2html1994"
  HREF="node18.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
<A NAME="tex2html1990"
  HREF="rute.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
<A NAME="tex2html1984"
  HREF="node16.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> 
<A NAME="tex2html1992"
  HREF="node1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A>  
<BR>
<B> Next:</B> <A NAME="tex2html1995"
  HREF="node18.html">15. Symbolic and Hard</A>
<B> Up:</B> <A NAME="tex2html1991"
  HREF="rute.html">rute</A>
<B> Previous:</B> <A NAME="tex2html1985"
  HREF="node16.html">13. LINUX Resources</A>
 &nbsp <B>  <A NAME="tex2html1993"
  HREF="node1.html">Contents</A></B> 
<BR>
<BR>
<!--End of Navigation Panel-->
<!--Table of Child-Links-->
<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></A>

<UL>
<LI><A NAME="tex2html1996"
  HREF="#SECTION001710000000000000000">14.1 The <TT>
<FONT COLOR="#0000ff">chmod</FONT></TT> Command</A>
<LI><A NAME="tex2html1997"
  HREF="#SECTION001720000000000000000">14.2 The <TT>
<FONT COLOR="#0000ff">umask</FONT></TT> Command</A>
<LI><A NAME="tex2html1998"
  HREF="#SECTION001730000000000000000">14.3 Modification Times: <TT>
<FONT COLOR="#0000ff">stat</FONT></TT></A>
</UL>
<!--End of Table of Child-Links-->
<HR>

<H1><A NAME="SECTION001700000000000000000">
14. Permission and Modification Times</A>
</H1>

<P>
<A NAME="chap:permmodtimes"></A>
<P>
Every file and directory on a U<SMALL>NIX</SMALL> system, besides being owned
by a user and a group, has access <I>flags</I> <FONT COLOR="#ffa500">[A switch
that can either be on or off.]</FONT> (also called <I>access bits</I>) dictating what kind of access that
user and group have to the file.

<P>
Running <TT>
<FONT COLOR="#0000ff">ls -ald /bin/cp /etc/passwd /tmp</FONT></TT> gives you a
listing like this:

<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>-rwxr-xr-x&nbsp;&nbsp;&nbsp;1&nbsp;root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;28628&nbsp;Mar&nbsp;24&nbsp;&nbsp;1999&nbsp;/bin/cp</code><br>
<code>-rw-r--r--&nbsp;&nbsp;&nbsp;1&nbsp;root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1151&nbsp;Jul&nbsp;23&nbsp;22:42&nbsp;/etc/passwd</code><br>
<code>drwxrwxrwt&nbsp;&nbsp;&nbsp;5&nbsp;root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4096&nbsp;Sep&nbsp;25&nbsp;15:23&nbsp;/tmp</code><br>
</FONT></TD></TR></TABLE><P>

<P>
In the leftmost column are flags which completely
describe the access rights to the file.

<P>
So far I have explained that the furthest flag to the left is either
<TT>
<FONT COLOR="#0000ff">-</FONT></TT> or <TT>
<FONT COLOR="#0000ff">d</FONT></TT>, indicating an ordinary file or directory. The
remaining nine have a <TT>
<FONT COLOR="#0000ff">-</FONT></TT> to indicate an unset value or
one of several possible characters. Table
<A HREF="node17.html#table:permissions">14.1</A> gives a complete description of file system permissions.

<P>
<BR><P></P>
<DIV ALIGN="CENTER"><A NAME="table:permissions"></A><A NAME="18523"></A>
<TABLE>
<CAPTION><STRONG>Table 14.1:</STRONG>
File and directory permissions</CAPTION>
<TR><TD><IMG
 WIDTH="556" HEIGHT="707" BORDER="0"
 SRC="img17.png"
 ALT="\begin{table}{\small\begin{tabularx}{1.0\textwidth}{\vert c \vert p{9ex} \vert X...
...ode{\color{blue}{T}}} has no effect.
\\
\par\hline
\end{tabularx}}
\end{table}"></TD></TR>
</TABLE>
</DIV><P></P>
<BR>

<P>

<H1><A NAME="SECTION001710000000000000000">
14.1 The <TT>
<FONT COLOR="#0000ff">chmod</FONT></TT> Command</A>
</H1>

<P>
You use the <TT>
<FONT COLOR="#0000ff">chmod</FONT></TT> command to change the permissions of
a file. It's usually used as follows:

<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code>&nbsp;</code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>chmod&nbsp;[-R]&nbsp;[u|g|o|a][+|-][r|w|x|s|t]&nbsp;&#060;file&#062;&nbsp;[&#060;file&#062;]&nbsp;...</code><br>
</FONT></TD></TR></TABLE><P>

<P>
For example,

<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code>&nbsp;</code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>chmod&nbsp;u+x&nbsp;myfile</code><br>
</FONT></TD></TR></TABLE><P>
adds execute permissions for the user of <TT>
<FONT COLOR="#0000ff">myfile</FONT></TT>. And,

<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code>&nbsp;</code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>chmod&nbsp;a-rx&nbsp;myfile</code><br>
</FONT></TD></TR></TABLE><P>
removes <TT>
<FONT COLOR="#0000ff">r</FONT></TT><I>ead</I> and <I>e</I><TT>
<FONT COLOR="#0000ff">x</FONT></TT><I>ecute</I> permissions
for <TT>
<FONT COLOR="#0000ff">a</FONT></TT><I>ll</I>--that is, user, group, and other.

<P>
The <TT>
<FONT COLOR="#0000ff">-R</FONT></TT> option, once again means <I>recursive</I>,
diving into subdirectories as usual.

<P>
Permission bits are often represented in their binary form,
especially in programs. It is convenient to show the
<TT>
<FONT COLOR="#0000ff">rwxrwxrwx</FONT></TT> set in octal, <FONT COLOR="#ffa500">[See Section <A HREF="node5.html#sec:binocthex">2.1</A>.]</FONT>where each digit fits
conveniently into three bits. Files on the system are usually
created with <I>mode</I> <TT>
<FONT COLOR="#0000ff">0644</FONT></TT>, meaning
<TT>
<FONT COLOR="#0000ff">rw-r&#45;&#45;r&#45;&#45;</FONT></TT>. You can set permissions explicitly with an octal
number, for example,

<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code>&nbsp;</code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>chmod&nbsp;0755&nbsp;myfile</code><br>
</FONT></TD></TR></TABLE><P>
gives <TT>
<FONT COLOR="#0000ff">myfile</FONT></TT> the permissions <TT>
<FONT COLOR="#0000ff">rwxr-xr-x</FONT></TT>. For a full list
of octal values for all kinds of permissions and file types, see
<TT>
<FONT COLOR="#0000ff">/usr/include/linux/stat.h</FONT></TT>.

<P>
In Table <A HREF="node17.html#table:permissions">14.1</A> you can see <TT>
<FONT COLOR="#0000ff">s</FONT></TT>, the <I>setuid</I> or
<I>setgid</I> bit. If it is used without execute permissions
then it has no meaning and is written as a capitalized <TT>
<FONT COLOR="#0000ff">S</FONT></TT>.
This bit effectively colorizes an <TT>
<FONT COLOR="#0000ff">x</FONT></TT> into an <TT>
<FONT COLOR="#0000ff">s</FONT></TT>,
so you should read an <TT>
<FONT COLOR="#0000ff">s</FONT></TT> as e<B><TT>
<FONT COLOR="#0000ff">x</FONT></TT></B>ecute
<I>with</I> the setuid or setgid bit set.
<TT>
<FONT COLOR="#0000ff">t</FONT></TT> is known as the <I>sticky</I> bit. It also has no
meaning if there are no execute permissions and is written as a capital
<TT>
<FONT COLOR="#0000ff">T</FONT></TT>.

<P>
The leading <TT>
<FONT COLOR="#0000ff">0</FONT></TT> can in be ignored, but is preferred for
explicitness. It <I>can</I> take on a value representing
the three bits, <I>setuid</I> (<TT>
<FONT COLOR="#0000ff">4</FONT></TT>), <I>setgid</I>
(<TT>
<FONT COLOR="#0000ff">2</FONT></TT>), and <I>sticky</I> (<TT>
<FONT COLOR="#0000ff">1</FONT></TT>). Hence a value of
<TT>
<FONT COLOR="#0000ff">5764</FONT></TT> is 
<FONT COLOR="#0000ff"><!-- MATH
 $101~111~110~100$
 -->
<IMG
 WIDTH="112" HEIGHT="15" ALIGN="BOTTOM" BORDER="0"
 SRC="img18.png"
 ALT="\bgroup\color{blue}$101~111~110~100$\egroup"></FONT> in binary and gives
<TT>
<FONT COLOR="#0000ff">-rwsrw-r-T</FONT></TT>.

<P>

<H1><A NAME="SECTION001720000000000000000">
14.2 The <TT>
<FONT COLOR="#0000ff">umask</FONT></TT> Command</A>
</H1>

<P>
<A NAME="sec:umask"></A>
<P>
<TT>
<FONT COLOR="#0000ff">umask</FONT></TT> sets the default permissions for newly created files; it
is usually <TT>
<FONT COLOR="#0000ff">022</FONT></TT>. This default value means that the permissions of any new
file you create (say, with the <TT>
<FONT COLOR="#0000ff">touch</FONT></TT> command) will be
<I>masked</I> with this number. <TT>
<FONT COLOR="#0000ff">022</FONT></TT> hence <I>excludes</I> write
permissions of <TT>
<FONT COLOR="#0000ff">g</FONT></TT>roup and of <TT>
<FONT COLOR="#0000ff">o</FONT></TT>ther. A <TT>
<FONT COLOR="#0000ff">umask</FONT></TT> of <TT>
<FONT COLOR="#0000ff">006</FONT></TT>
would exclude read and write permissions of <TT>
<FONT COLOR="#0000ff">o</FONT></TT>ther, but would allow read
and write of <TT>
<FONT COLOR="#0000ff">g</FONT></TT>roup. Try

<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<font size="-1"><code>5</code></font><code>&nbsp;</code><br>
<code>&nbsp;</code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>umask</code><br>
<code>touch&nbsp;&#060;file1&#062;</code><br>
<code>ls&nbsp;-al&nbsp;&#060;file1&#062;</code><br>
<code>umask&nbsp;026</code><br>
<code>touch&nbsp;&#060;file2&#062;</code><br>
<code>ls&nbsp;-al&nbsp;&#060;file2&#062;</code><br>
</FONT></TD></TR></TABLE><P>
<TT>
<FONT COLOR="#0000ff">026</FONT></TT> is probably closer to the kind of mask we like
as an ordinary user. Check your <TT>
<FONT COLOR="#0000ff">/etc/profile</FONT></TT> file to see
what <TT>
<FONT COLOR="#0000ff">umask</FONT></TT> your login defaults to, when, and also why.

<P>

<H1><A NAME="SECTION001730000000000000000">
14.3 Modification Times: <TT>
<FONT COLOR="#0000ff">stat</FONT></TT></A>
</H1>

<P>
In addition to permissions, each file has three integers associated with
it that represent, in seconds, the last time the file was accessed
(read), when it was last modified (written to), and when its permissions
were last changed. These are known as the <I>atime</I>, <I>mtime</I>, and
<I>ctime</I> of a file respectively.

<P>
To get a complete listing of the file's permissions, use the <TT>
<FONT COLOR="#0000ff">stat</FONT></TT>
command. Here is the result of <TT>
<FONT COLOR="#0000ff">stat /etc</FONT></TT>:

<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<font size="-1"><code>5</code></font><code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>&nbsp;&nbsp;File:&nbsp;"/etc"</code><br>
<code>&nbsp;&nbsp;Size:&nbsp;4096&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Filetype:&nbsp;Directory</code><br>
<code>&nbsp;&nbsp;Mode:&nbsp;(0755/drwxr-xr-x)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Uid:&nbsp;(&nbsp;&nbsp;&nbsp;&nbsp;0/&nbsp;&nbsp;&nbsp;&nbsp;root)&nbsp;&nbsp;Gid:&nbsp;(&nbsp;&nbsp;&nbsp;&nbsp;0/&nbsp;&nbsp;&nbsp;&nbsp;root)</code><br>
<code>Device:&nbsp;&nbsp;3,1&nbsp;&nbsp;&nbsp;Inode:&nbsp;14057&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Links:&nbsp;41&nbsp;&nbsp;&nbsp;</code><br>
<code>Access:&nbsp;Sat&nbsp;Sep&nbsp;25&nbsp;04:09:08&nbsp;1999(00000.15:02:23)</code><br>
<code>Modify:&nbsp;Fri&nbsp;Sep&nbsp;24&nbsp;20:55:14&nbsp;1999(00000.22:16:17)</code><br>
<code>Change:&nbsp;Fri&nbsp;Sep&nbsp;24&nbsp;20:55:14&nbsp;1999(00000.22:16:17)</code><br>
</FONT></TD></TR></TABLE><P>
The <TT>
<FONT COLOR="#0000ff">Size:</FONT></TT> quoted here is the actual amount of disk space
used to store the directory <I>listing</I>, and
is the same as reported by <TT>
<FONT COLOR="#0000ff">ls</FONT></TT>. In this case it is
probably four disk blocks of 1024 bytes each. The size of a
directory as quoted here does <I>not</I> mean the sum of all
files contained under it. For a file, however, the <TT>
<FONT COLOR="#0000ff">Size:</FONT></TT> would
be the exact file length in bytes (again, as reported by <TT>
<FONT COLOR="#0000ff">ls</FONT></TT>).

<P>
<HR>
<!--Navigation Panel-->
<A NAME="tex2html1994"
  HREF="node18.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
<A NAME="tex2html1990"
  HREF="rute.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
<A NAME="tex2html1984"
  HREF="node16.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> 
<A NAME="tex2html1992"
  HREF="node1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A>  
<BR>
<B> Next:</B> <A NAME="tex2html1995"
  HREF="node18.html">15. Symbolic and Hard</A>
<B> Up:</B> <A NAME="tex2html1991"
  HREF="rute.html">rute</A>
<B> Previous:</B> <A NAME="tex2html1985"
  HREF="node16.html">13. LINUX Resources</A>
 &nbsp <B>  <A NAME="tex2html1993"
  HREF="node1.html">Contents</A></B> 
<!--End of Navigation Panel-->

</BODY>
</HTML>