~ubuntu-branches/ubuntu/feisty/findutils/feisty

« back to all changes in this revision

Viewing changes to doc/perm.texi

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Metzler
  • Date: 2006-08-06 09:53:05 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20060806095305-265uqmwsguy8vfjq
Tags: 4.2.28-1
* New upstream version.
 - includes 01_updatedb-withnew-su.dpatch, drop it.

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
Files are given an owner and group when they are created.  Usually the
47
47
owner is the current user and the group is the group of the directory
48
48
the file is in, but this varies with the operating system, the
49
 
filesystem the file is created on, and the way the file is created.  You
50
 
can change the owner and group of a file by using the @code{chown} and
51
 
@code{chgrp} commands.
 
49
file system the file is created on, and the way the file is created.  You
 
50
can change the owner and group of a file by using the @command{chown} and
 
51
@command{chgrp} commands.
52
52
 
53
53
In addition to the three sets of three permissions listed above, a
54
54
file's permissions have three special components, which affect only
57
57
@enumerate
58
58
@item
59
59
@cindex setuid
60
 
set the process's effective user ID to that of the file upon execution
 
60
Set the process's effective user ID to that of the file upon execution
61
61
(called the @dfn{setuid bit}).  No effect on directories.
62
62
@item
63
63
@cindex setgid
64
 
set the process's effective group ID to that of the file upon execution
 
64
Set the process's effective group ID to that of the file upon execution
65
65
(called the @dfn{setgid bit}).  For directories on some systems, put
66
66
files created in the directory into the same group as the directory, no
67
67
matter what group the user who creates them is in.
69
69
@cindex sticky
70
70
@cindex swap space, saving text image in
71
71
@cindex text image, saving in swap space
72
 
@cindex append-only directories
73
 
save the program's text image on the swap device so it will load more
74
 
quickly when run (called the @dfn{sticky bit}).  For directories on some
75
 
systems, prevent users from removing files that they do not own in the
76
 
directory; this is called making the directory @dfn{append-only}.
 
72
@cindex restricted deletion flag
 
73
prevent users from removing or renaming a file in a directory
 
74
unless they own the file or the directory; this is called the
 
75
@dfn{restricted deletion flag} for the directory.
 
76
For regular files on some systems, save the program's text image on the
 
77
swap device so it will load more quickly when run; this is called the
 
78
@dfn{sticky bit}.
77
79
@end enumerate
78
80
 
 
81
In addition to the permissions listed above, there may be file attributes
 
82
specific to the file system, e.g: access control lists (ACLs), whether a
 
83
file is compressed, whether a file can be modified (immutability), whether
 
84
a file can be dumped.  These are usually set using programs
 
85
specific to the file system.  For example:
 
86
@c should probably say a lot more about ACLs... someday
 
87
 
 
88
@table @asis
 
89
@item ext2
 
90
On @acronym{GNU} and @acronym{GNU}/Linux the file permissions
 
91
(``attributes'') specific to
 
92
the ext2 file system are set using @command{chattr}.
 
93
 
 
94
@item FFS
 
95
On FreeBSD the file permissions (``flags'') specific to the FFS
 
96
file system are set using @command{chrflags}.
 
97
@end table
 
98
 
 
99
Although a file's permission ``bits'' allow an operation on that file,
 
100
that operation may still fail, because:
 
101
 
 
102
@itemize
 
103
@item
 
104
the file-system-specific permissions do not permit it;
 
105
 
 
106
@item
 
107
the file system is mounted as read-only.
 
108
@end itemize
 
109
 
 
110
For example, if the immutable attribute is set on a file,
 
111
it cannot be modified, regardless of the fact that you
 
112
may have just run @code{chmod a+w FILE}.
 
113
 
79
114
@node Symbolic Modes
80
115
@section Symbolic Modes
81
116
 
89
124
The format of symbolic modes is:
90
125
 
91
126
@example
92
 
@r{[}ugoa@dots{}@r{][[}+-=@r{][}rwxXstugo@dots{}@r{]}@dots{}@r{][},@dots{}@r{]}
 
127
@r{[}ugoa@dots{}@r{][}+-=@r{]}@var{perms}@dots{}@r{[},@dots{}@r{]}
93
128
@end example
94
129
 
 
130
@noindent
 
131
where @var{perms} is either zero or more letters from the set
 
132
@samp{rwxXst}, or a single letter from the set @samp{ugo}.
 
133
 
95
134
The following sections describe the operators and other details of
96
135
symbolic modes.
97
136
 
118
157
 
119
158
@noindent
120
159
The spaces between the three parts above are shown for readability only;
121
 
symbolic modes can not contain spaces.
 
160
symbolic modes cannot contain spaces.
122
161
 
123
162
The @var{users} part tells which users' access to the file is changed.
124
163
It consists of one or more of the following letters (or it can be empty;
160
199
@end table
161
200
 
162
201
The @var{permissions} part tells what kind of access to the file should
163
 
be changed; it is zero or more of the following letters.  As with the
 
202
be changed; it is normally zero or more of the following letters.  As with the
164
203
@var{users} part, the order does not matter when more than one letter is
165
204
given.  Omitting the @var{permissions} part is useful only with the
166
205
@samp{=} operation, where it gives the specified @var{users} no access
185
224
a=rw
186
225
@end example
187
226
 
188
 
To remove write permission for from all users other than the file's
 
227
To remove write permission for all users other than the file's
189
228
owner, use:
190
229
 
191
230
@example
209
248
Another way to specify the same thing is:
210
249
 
211
250
@example
212
 
og-rxw
 
251
og-rwx
213
252
@end example
214
253
 
215
254
@node Copying Permissions
217
256
 
218
257
@cindex copying existing permissions
219
258
@cindex permissions, copying existing
220
 
You can base part of a file's permissions on part of its existing
221
 
permissions.  To do this, instead of using @samp{r}, @samp{w}, or
222
 
@samp{x} after the operator, you use the letter @samp{u}, @samp{g}, or
223
 
@samp{o}.  For example, the mode
 
259
You can base a file's permissions on its existing permissions.  To do
 
260
this, instead of using a series of @samp{r}, @samp{w}, or @samp{x}
 
261
letters after the
 
262
operator, you use the letter @samp{u}, @samp{g}, or @samp{o}.  For
 
263
example, the mode
224
264
 
225
265
@example
226
266
o+g
227
267
@end example
228
268
 
229
269
@noindent
230
 
@c FIXME describe the ls -l notation for showing permissions.
231
270
adds the permissions for users who are in a file's group to the
232
271
permissions that other users have for the file.  Thus, if the file
233
272
started out as mode 664 (@samp{rw-rw-r--}), the above mode would change
252
291
@samp{g} in the @var{users} part of the symbolic mode and
253
292
@samp{s} in the @var{permissions} part.
254
293
 
255
 
To change a file's permission to stay permanently on the swap device,
256
 
use @samp{o} in the @var{users} part of the symbolic mode and
 
294
To change a file's permission to set the restricted deletion flag or sticky bit,
 
295
omit the @var{users} part of the symbolic mode (or use @samp{a}) and put
257
296
@samp{t} in the @var{permissions} part.
258
297
 
259
 
For example, to add set user ID permission to a program,
 
298
For example, to add set-user-ID permission to a program,
260
299
you can use the mode:
261
300
 
262
301
@example
263
302
u+s
264
303
@end example
265
304
 
266
 
To remove both set user ID and set group ID permission from
 
305
To remove both set-user-ID and set-group-ID permission from
267
306
it, you can use the mode:
268
307
 
269
308
@example
270
309
ug-s
271
310
@end example
272
311
 
273
 
To cause a program to be saved on the swap device, you can use
 
312
To set the restricted deletion flag or sticky bit, you can use
274
313
the mode:
275
314
 
276
315
@example
277
 
o+t
278
 
@end example
279
 
 
280
 
Remember that the special permissions only affect files that are
281
 
executable, plus, on some systems, directories (on which they have
282
 
different meanings; @pxref{Mode Structure}).  Using @samp{a}
283
 
in the @var{users} part of a symbolic mode does not cause the special
284
 
permissions to be affected; thus,
285
 
 
286
 
@example
287
 
a+s
288
 
@end example
289
 
 
290
 
@noindent
291
 
has @emph{no effect}.  You must use @samp{u}, @samp{g}, and @samp{o}
292
 
explicitly to affect the special permissions.  Also, the
293
 
combinations @samp{u+t}, @samp{g+t}, and @samp{o+s} have no effect.
 
316
+t
 
317
@end example
 
318
 
 
319
The combination @samp{o+s} has no effect.  On @acronym{GNU} systems
 
320
the combinations @samp{u+t} and @samp{g+t} have no effect, and
 
321
@samp{o+t} acts like plain @samp{+t}.
294
322
 
295
323
The @samp{=} operator is not very useful with special permissions; for
296
324
example, the mode:
300
328
@end example
301
329
 
302
330
@noindent
303
 
does cause the file to be saved on the swap device, but it also
 
331
does set the restricted deletion flag or sticky bit, but it also
304
332
removes all read, write, and execute permissions that users not in the
305
333
file's group might have had for it.
306
334
 
310
338
@cindex conditional executability
311
339
There is one more special type of symbolic permission: if you use
312
340
@samp{X} instead of @samp{x}, execute permission is affected only if the
313
 
file already had execute permission or is a directory.  It affects
314
 
directories' execute permission even if they did not initially have any
315
 
execute permissions set.
 
341
file is a directory or already had execute permission.
316
342
 
317
343
For example, this mode:
318
344
 
321
347
@end example
322
348
 
323
349
@noindent
324
 
gives all users permission to execute files (or search directories) if
325
 
anyone could before.
 
350
gives all users permission to search directories, or to execute files if
 
351
anyone could execute them before.
326
352
 
327
353
@node Multiple Changes
328
354
@subsection Making Multiple Changes
345
371
gives users other than the owner of the file read permission and, if
346
372
it is a directory or if someone already had execute permission
347
373
to it, gives them execute permission; and it also denies them write
348
 
permission to it file.  It does not affect the permission that the
 
374
permission to the file.  It does not affect the permission that the
349
375
owner of the file has for it.  The above mode is equivalent to
350
376
the two modes:
351
377
 
433
459
@cindex numeric modes
434
460
@cindex file permissions, numeric
435
461
@cindex octal numbers for file modes
436
 
File permissions are stored internally as 16 bit integers.  As an
 
462
As an
437
463
alternative to giving a symbolic mode, you can give an octal (base 8)
438
 
number that corresponds to the internal representation of the new mode.
 
464
number that represents the new mode.
439
465
This number is always interpreted in octal; you do not have to add a
440
466
leading 0, as you do in C.  Mode 0055 is the same as mode 55.
441
467
 
442
468
A numeric mode is usually shorter than the corresponding symbolic
443
 
mode, but it is limited in that it can not take into account a file's
 
469
mode, but it is limited in that it cannot take into account a file's
444
470
previous permissions; it can only set them absolutely.
445
471
 
446
 
The permissions granted to the user, to other users in the file's group,
447
 
and to other users not in the file's group are each stored as three
 
472
The permissions granted to the user,
 
473
to other users in the file's group,
 
474
and to other users not in the file's group each require three
448
475
bits, which are represented as one octal digit.  The three special
449
 
permissions are also each stored as one bit, and they are as a group
450
 
represented as another octal digit.  Here is how the bits are arranged
451
 
in the 16 bit integer, starting with the lowest valued bit:
 
476
permissions also require one bit each, and they are as a group
 
477
represented as another octal digit.  Here is how the bits are arranged,
 
478
starting with the lowest valued bit:
452
479
 
453
480
@example
454
481
Value in  Corresponding
470
497
 400      Read
471
498
 
472
499
          Special permissions:
473
 
1000      Save text image on swap device
 
500
1000      Restricted deletion flag or sticky bit
474
501
2000      Set group ID on execution
475
502
4000      Set user ID on execution
476
503
@end example
478
505
For example, numeric mode 4755 corresponds to symbolic mode
479
506
@samp{u=rwxs,go=rx}, and numeric mode 664 corresponds to symbolic mode
480
507
@samp{ug=rw,o=r}.  Numeric mode 0 corresponds to symbolic mode
481
 
@samp{ugo=}.
482
 
 
483
 
@comment texi related words used by Emacs' spell checker ispell.el
484
 
 
485
 
@comment LocalWords: texinfo setfilename settitle setchapternewpage
486
 
@comment LocalWords: iftex finalout ifinfo DIR titlepage vskip pt
487
 
@comment LocalWords: filll dir samp dfn noindent xref pxref
488
 
@comment LocalWords: var deffn texi deffnx itemx emph asis
489
 
@comment LocalWords: findex smallexample subsubsection cindex
490
 
 
491
 
@comment LocalWords: chgrp chown executability filesystem FIXME ls og rw
492
 
@comment LocalWords: rwx rwxr rwxs rwxXstugo rx rX rxw setgid setuid ug
493
 
@comment LocalWords: ugo ugoa umask
 
508
@samp{a=}.