~ubuntu-branches/ubuntu/utopic/coreutils/utopic-proposed

« back to all changes in this revision

Viewing changes to doc/perm.texi

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-11-28 03:03:42 UTC
  • mfrom: (8.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20121128030342-21zanj8354gas5gr
Tags: 8.20-3ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Make 'uname -i -p' return the real processor/hardware, instead of
    unknown.
  - Build-depend on gettext:any instead of on gettext, so that apt-get can
    properly resolve build-dependencies on the tool when cross-building.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
@c File mode bits
2
2
 
3
 
@c Copyright (C) 1994, 1996, 1999-2001, 2003-2006, 2008-2011 Free Software
4
 
@c Foundation, Inc.
 
3
@c Copyright (C) 1994-2012 Free Software Foundation, Inc.
5
4
 
6
5
@c Permission is granted to copy, distribute and/or modify this document
7
6
@c under the terms of the GNU Free Documentation License, Version 1.3 or
18
17
* Mode Structure::              Structure of file mode bits.
19
18
* Symbolic Modes::              Mnemonic representation of file mode bits.
20
19
* Numeric Modes::               File mode bits as octal numbers.
 
20
* Operator Numeric Modes::      ANDing, ORing, and setting modes octally.
21
21
* Directory Setuid and Setgid:: Set-user-ID and set-group-ID on directories.
22
22
@end menu
23
23
 
112
112
 
113
113
@table @asis
114
114
@item ext2
115
 
On @acronym{GNU} and @acronym{GNU}/Linux the file attributes specific to
 
115
On GNU and GNU/Linux the file attributes specific to
116
116
the ext2 file system are set using @command{chattr}.
117
117
 
118
118
@item FFS
345
345
+t
346
346
@end example
347
347
 
348
 
The combination @samp{o+s} has no effect.  On @acronym{GNU} systems
 
348
The combination @samp{o+s} has no effect.  On GNU systems
349
349
the combinations @samp{u+t} and @samp{g+t} have no effect, and
350
350
@samp{o+t} acts like plain @samp{+t}.
351
351
 
496
496
number that represents the mode.
497
497
This number is always interpreted in octal; you do not have to add a
498
498
leading @samp{0}, as you do in C.  Mode @samp{0055} is the same as
499
 
mode @samp{55}.
 
499
mode @samp{55}.  (However, modes of five digits or more, such as
 
500
@samp{00055}, are sometimes special.  @xref{Directory Setuid and Setgid}.)
500
501
 
501
502
A numeric mode is usually shorter than the corresponding symbolic
502
503
mode, but it is limited in that normally it cannot take into account the
503
504
previous file mode bits; it can only set them absolutely.
504
 
(As discussed in the next section, the set-user-ID and set-group-ID
505
 
bits of directories are an exception to this general limitation.)
 
505
The set-user-ID and set-group-ID bits of directories are an exception
 
506
to this general limitation.  @xref{Directory Setuid and Setgid}.
 
507
Also, operator numeric modes can take previous file mode bits into
 
508
account.  @xref{Operator Numeric Modes}.
506
509
 
507
510
The permissions granted to the user,
508
511
to other users in the file's group,
542
545
@samp{ug=rw,o=r}.  Numeric mode @samp{0} corresponds to symbolic mode
543
546
@samp{a=}.
544
547
 
 
548
@node Operator Numeric Modes
 
549
@section Operator Numeric Modes
 
550
 
 
551
An operator numeric mode is a numeric mode that is prefixed by a
 
552
@samp{-}, @samp{+}, or @samp{=} operator, which has the same
 
553
interpretation as in symbolic modes.  For example, @samp{+440} enables
 
554
read permission for the file's owner and group, @samp{-1} disables
 
555
execute permission for other users, and @samp{=600} clears all
 
556
permissions except for enabling read-write permissions for the file's
 
557
owner.  Operator numeric modes can be combined with symbolic modes by
 
558
separating them with a comma; for example, @samp{=0,u+r} clears all
 
559
permissions except for enabling read permission for the file's owner.
 
560
 
 
561
The commands @samp{chmod =755 @var{dir}} and @samp{chmod 755
 
562
@var{dir}} differ in that the former clears the directory @var{dir}'s
 
563
setuid and setgid bits, whereas the latter preserves them.
 
564
@xref{Directory Setuid and Setgid}.
 
565
 
 
566
Operator numeric modes are a GNU extension.
 
567
 
545
568
@node Directory Setuid and Setgid
546
569
@section Directories and the Set-User-ID and Set-Group-ID Bits
547
570
 
560
583
mechanisms would be less convenient and it would be harder to share
561
584
files.  Therefore, a command like @command{chmod} does not affect the
562
585
set-user-ID or set-group-ID bits of a directory unless the user
563
 
specifically mentions them in a symbolic mode, or sets them in
564
 
a numeric mode.  For example, on systems that support
 
586
specifically mentions them in a symbolic mode, or uses an operator
 
587
numeric mode such as @samp{=755}, or sets them in a numeric mode, or
 
588
clears them in a numeric mode that has five or more octal digits.
 
589
For example, on systems that support
565
590
set-group-ID inheritance:
566
591
 
567
592
@example
583
608
@example
584
609
# These commands try to set the set-user-ID
585
610
# and set-group-ID bits of the subdirectories.
586
 
mkdir G H
 
611
mkdir G
587
612
chmod 6755 G
588
 
chmod u=rwx,go=rx,a+s H
589
 
mkdir -m 6755 I
 
613
chmod +6000 G
 
614
chmod u=rwx,go=rx,a+s G
 
615
mkdir -m 6755 H
 
616
mkdir -m +6000 I
590
617
mkdir -m u=rwx,go=rx,a+s J
591
618
@end example
592
619
 
593
620
If you want to try to clear these bits, you must mention them
594
 
explicitly in a symbolic mode, e.g.:
 
621
explicitly in a symbolic mode, or use an operator numeric mode, or
 
622
specify a numeric mode with five or more octal digits, e.g.:
595
623
 
596
624
@example
597
 
# This command tries to clear the set-user-ID
 
625
# These commands try to clear the set-user-ID
598
626
# and set-group-ID bits of the directory D.
599
627
chmod a-s D
 
628
chmod -6000 D
 
629
chmod =755 D
 
630
chmod 00755 D
600
631
@end example
601
632
 
602
 
This behavior is a @acronym{GNU} extension.  Portable scripts should
 
633
This behavior is a GNU extension.  Portable scripts should
603
634
not rely on requests to set or clear these bits on directories, as
604
 
@acronym{POSIX} allows implementations to ignore these requests.
 
635
POSIX allows implementations to ignore these requests.
 
636
The GNU behavior with numeric modes of four or fewer digits
 
637
is intended for scripts portable to systems that preserve these bits;
 
638
the behavior with numeric modes of five or more digits is for scripts
 
639
portable to systems that do not preserve the bits.