home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / findutils-4.1-bin.lha / info / find.info-2 (.txt) < prev   
GNU Info File  |  1996-10-12  |  38KB  |  746 lines

  1. This is Info file find.info, produced by Makeinfo-1.63 from the input
  2. file /ade-src/fsf/findutils/doc/find.texi.
  3. START-INFO-DIR-ENTRY
  4. * Finding Files: (find).        Listing and operating on files
  5.                                 that match certain criteria.
  6. END-INFO-DIR-ENTRY
  7.    This file documents the GNU utilities for finding files that match
  8. certain criteria and performing various operations on them.
  9.    Copyright (C) 1994 Free Software Foundation, Inc.
  10.    Permission is granted to make and distribute verbatim copies of this
  11. manual provided the copyright notice and this permission notice are
  12. preserved on all copies.
  13.    Permission is granted to copy and distribute modified versions of
  14. this manual under the conditions for verbatim copying, provided that
  15. the entire resulting derived work is distributed under the terms of a
  16. permission notice identical to this one.
  17.    Permission is granted to copy and distribute translations of this
  18. manual into another language, under the above conditions for modified
  19. versions, except that this permission notice may be stated in a
  20. translation approved by the Foundation.
  21. File: find.info,  Node: Viewing And Editing,  Next: Archiving,  Up: Common Tasks
  22. Viewing And Editing
  23. ===================
  24.    To view a list of files that meet certain criteria, simply run your
  25. file viewing program with the file names as arguments.  Shells
  26. substitute a command enclosed in backquotes with its output, so the
  27. whole command looks like this:
  28.      less `find /usr/include -name '*.h' | xargs grep -l mode_t`
  29. You can edit those files by giving an editor name instead of a file
  30. viewing program.
  31. File: find.info,  Node: Archiving,  Next: Cleaning Up,  Prev: Viewing And Editing,  Up: Common Tasks
  32. Archiving
  33. =========
  34.    You can pass a list of files produced by `find' to a file archiving
  35. program.  GNU `tar' and `cpio' can both read lists of file names from
  36. the standard input--either delimited by nulls (the safe way) or by
  37. blanks (the lazy, risky default way).  To use null-delimited names,
  38. give them the `--null' option.  You can store a file archive in a file,
  39. write it on a tape, or send it over a network to extract on another
  40. machine.
  41.    One common use of `find' to archive files is to send a list of the
  42. files in a directory tree to `cpio'.  Use `-depth' so if a directory
  43. does not have write permission for its owner, its contents can still be
  44. restored from the archive since the directory's permissions are
  45. restored after its contents.  Here is an example of doing this using
  46. `cpio'; you could use a more complex `find' expression to archive only
  47. certain files.
  48.      find . -depth -print0 |
  49.        cpio --create --null --format=crc --file=/dev/nrst0
  50.    You could restore that archive using this command:
  51.      cpio --extract --null --make-dir --unconditional \
  52.        --preserve --file=/dev/nrst0
  53.    Here are the commands to do the same things using `tar':
  54.      find . -depth -print0 |
  55.        tar --create --null --files-from=- --file=/dev/nrst0
  56.      
  57.      tar --extract --null --preserve-perm --same-owner \
  58.        --file=/dev/nrst0
  59.    Here is an example of copying a directory from one machine to
  60. another:
  61.      find . -depth -print0 | cpio -0o -Hnewc |
  62.        rsh OTHER-MACHINE "cd `pwd` && cpio -i0dum"
  63. File: find.info,  Node: Cleaning Up,  Next: Strange File Names,  Prev: Archiving,  Up: Common Tasks
  64. Cleaning Up
  65. ===========
  66.    This section gives examples of removing unwanted files in various
  67. situations.  Here is a command to remove the CVS backup files created
  68. when an update requires a merge:
  69.      find . -name '.#*' -print0 | xargs -0r rm -f
  70.    You can run this command to clean out your clutter in `/tmp'.  You
  71. might place it in the file your shell runs when you log out
  72. (`.bash_logout', `.logout', or `.zlogout', depending on which shell you
  73. use).
  74.      find /tmp -user $LOGNAME -type f -print0 | xargs -0 -r rm -f
  75.    To remove old Emacs backup and auto-save files, you can use a command
  76. like the following.  It is especially important in this case to use
  77. null-terminated file names because Emacs packages like the VM mailer
  78. often create temporary file names with spaces in them, like `#reply to
  79. David J. MacKenzie<1>#'.
  80.      find ~ \( -name '*~' -o -name '#*#' \) -print0 |
  81.        xargs --no-run-if-empty --null rm -vf
  82.    Removing old files from `/tmp' is commonly done from `cron':
  83.      find /tmp /var/tmp -not -type d -mtime +3 -print0 |
  84.        xargs --null --no-run-if-empty rm -f
  85.      
  86.      find /tmp /var/tmp -depth -mindepth 1 -type d -empty -print0 |
  87.        xargs --null --no-run-if-empty rmdir
  88.    The second `find' command above uses `-depth' so it cleans out empty
  89. directories depth-first, hoping that the parents become empty and can
  90. be removed too.  It uses `-mindepth' to avoid removing `/tmp' itself if
  91. it becomes totally empty.
  92. File: find.info,  Node: Strange File Names,  Next: Fixing Permissions,  Prev: Cleaning Up,  Up: Common Tasks
  93. Strange File Names
  94. ==================
  95.    `find' can help you remove or rename a file with strange characters
  96. in its name.  People are sometimes stymied by files whose names contain
  97. characters such as spaces, tabs, control characters, or characters with
  98. the high bit set.  The simplest way to remove such files is:
  99.      rm -i SOME*PATTERN*THAT*MATCHES*THE*PROBLEM*FILE
  100.    `rm' asks you whether to remove each file matching the given
  101. pattern.  If you are using an old shell, this approach might not work if
  102. the file name contains a character with the high bit set; the shell may
  103. strip it off.  A more reliable way is:
  104.      find . -maxdepth 1 TESTS -ok rm '{}' \;
  105. where TESTS uniquely identify the file.  The `-maxdepth 1' option
  106. prevents `find' from wasting time searching for the file in any
  107. subdirectories; if there are no subdirectories, you may omit it.  A
  108. good way to uniquely identify the problem file is to figure out its
  109. inode number; use
  110.      ls -i
  111.    Suppose you have a file whose name contains control characters, and
  112. you have found that its inode number is 12345.  This command prompts
  113. you for whether to remove it:
  114.      find . -maxdepth 1 -inum 12345 -ok rm -f '{}' \;
  115.    If you don't want to be asked, perhaps because the file name may
  116. contain a strange character sequence that will mess up your screen when
  117. printed, then use `-exec' instead of `-ok'.
  118.    If you want to rename the file instead, you can use `mv' instead of
  119. `rm':
  120.      find . -maxdepth 1 -inum 12345 -ok mv '{}' NEW-FILE-NAME \;
  121. File: find.info,  Node: Fixing Permissions,  Next: Classifying Files,  Prev: Strange File Names,  Up: Common Tasks
  122. Fixing Permissions
  123. ==================
  124.    Suppose you want to make sure that everyone can write to the
  125. directories in a certain directory tree.  Here is a way to find
  126. directories lacking either user or group write permission (or both),
  127. and fix their permissions:
  128.      find . -type d -not -perm -ug=w | xargs chmod ug+w
  129. You could also reverse the operations, if you want to make sure that
  130. directories do *not* have world write permission.
  131. File: find.info,  Node: Classifying Files,  Prev: Fixing Permissions,  Up: Common Tasks
  132. Classifying Files
  133. =================
  134.    If you want to classify a set of files into several groups based on
  135. different criteria, you can use the comma operator to perform multiple
  136. independent tests on the files.  Here is an example:
  137.      find / -type d \( -perm -o=w -fprint allwrite , \
  138.        -perm -o=x -fprint allexec \)
  139.      
  140.      echo "Directories that can be written to by everyone:"
  141.      cat allwrite
  142.      echo ""
  143.      echo "Directories with search permissions for everyone:"
  144.      cat allexec
  145.    `find' has only to make one scan through the directory tree (which
  146. is one of the most time consuming parts of its work).
  147. File: find.info,  Node: Databases,  Next: File Permissions,  Prev: Common Tasks,  Up: Top
  148. File Name Databases
  149. *******************
  150.    The file name databases used by `locate' contain lists of files that
  151. were in particular directory trees when the databases were last
  152. updated.  The file name of the default database is determined when
  153. `locate' and `updatedb' are configured and installed.  The frequency
  154. with which the databases are updated and the directories for which they
  155. contain entries depend on how often `updatedb' is run, and with which
  156. arguments.
  157. * Menu:
  158. * Database Locations::
  159. * Database Formats::
  160. File: find.info,  Node: Database Locations,  Next: Database Formats,  Up: Databases
  161. Database Locations
  162. ==================
  163.    There can be multiple file name databases.  Users can select which
  164. databases `locate' searches using an environment variable or a command
  165. line option.  The system administrator can choose the file name of the
  166. default database, the frequency with which the databases are updated,
  167. and the directories for which they contain entries.  File name
  168. databases are updated by running the `updatedb' program, typically
  169. nightly.
  170.    In networked environments, it often makes sense to build a database
  171. at the root of each filesystem, containing the entries for that
  172. filesystem.  `updatedb' is then run for each filesystem on the
  173. fileserver where that filesystem is on a local disk, to prevent
  174. thrashing the network.  Here are the options to `updatedb' to select
  175. which directories each database contains entries for:
  176. `--localpaths='PATH...''
  177.      Non-network directories to put in the database.  Default is `/'.
  178. `--netpaths='PATH...''
  179.      Network (NFS, AFS, RFS, etc.) directories to put in the database.
  180.      Default is none.
  181. `--prunepaths='PATH...''
  182.      Directories to not put in the database, which would otherwise be.
  183.      Default is `/tmp /usr/tmp /var/tmp /afs'.
  184. `--output=DBFILE'
  185.      The database file to build.  Default is system-dependent, but
  186.      typically `/usr/local/var/locatedb'.
  187. `--netuser=USER'
  188.      The user to search network directories as, using `su'.  Default is
  189.      `daemon'.
  190. File: find.info,  Node: Database Formats,  Prev: Database Locations,  Up: Databases
  191. Database Formats
  192. ================
  193.    The file name databases contain lists of files that were in
  194. particular directory trees when the databases were last updated.  The
  195. file name database format changed starting with GNU `locate' version
  196. 4.0 to allow machines with diffent byte orderings to share the
  197. databases.  The new GNU `locate' can read both the old and new database
  198. formats.  However, old versions of `locate' and `find' produce incorrect
  199. results if given a new-format database.
  200. * Menu:
  201. * New Database Format::
  202. * Sample Database::
  203. * Old Database Format::
  204. File: find.info,  Node: New Database Format,  Next: Sample Database,  Up: Database Formats
  205. New Database Format
  206. -------------------
  207.    `updatedb' runs a program called `frcode' to "front-compress" the
  208. list of file names, which reduces the database size by a factor of 4 to
  209. 5.  Front-compression (also known as incremental encoding) works as
  210. follows.
  211.    The database entries are a sorted list (case-insensitively, for
  212. users' convenience).  Since the list is sorted, each entry is likely to
  213. share a prefix (initial string) with the previous entry.  Each database
  214. entry begins with an offset-differential count byte, which is the
  215. additional number of characters of prefix of the preceding entry to use
  216. beyond the number that the preceding entry is using of its predecessor.
  217. (The counts can be negative.)  Following the count is a
  218. null-terminated ASCII remainder--the part of the name that follows the
  219. shared prefix.
  220.    If the offset-differential count is larger than can be stored in a
  221. byte (+/-127), the byte has the value 0x80 and the count follows in a
  222. 2-byte word, with the high byte first (network byte order).
  223.    Every database begins with a dummy entry for a file called
  224. `LOCATE02', which `locate' checks for to ensure that the database file
  225. has the correct format; it ignores the entry in doing the search.
  226.    Databases can not be concatenated together, even if the first (dummy)
  227. entry is trimmed from all but the first database.  This is because the
  228. offset-differential count in the first entry of the second and following
  229. databases will be wrong.
  230. File: find.info,  Node: Sample Database,  Next: Old Database Format,  Prev: New Database Format,  Up: Database Formats
  231. Sample Database
  232. ---------------
  233.    Sample input to `frcode':
  234.      /usr/src
  235.      /usr/src/cmd/aardvark.c
  236.      /usr/src/cmd/armadillo.c
  237.      /usr/tmp/zoo
  238.    Length of the longest prefix of the preceding entry to share:
  239.      0 /usr/src
  240.      8 /cmd/aardvark.c
  241.      14 rmadillo.c
  242.      5 tmp/zoo
  243.    Output from `frcode', with trailing nulls changed to newlines and
  244. count bytes made printable:
  245.      0 LOCATE02
  246.      0 /usr/src
  247.      8 /cmd/aardvark.c
  248.      6 rmadillo.c
  249.      -9 tmp/zoo
  250.    (6 = 14 - 8, and -9 = 5 - 14)
  251. File: find.info,  Node: Old Database Format,  Prev: Sample Database,  Up: Database Formats
  252. Old Database Format
  253. -------------------
  254.    The old database format is used by Unix `locate' and `find' programs
  255. and earlier releases of the GNU ones.  `updatedb' produces this format
  256. if given the `--old-format' option.
  257.    `updatedb' runs programs called `bigram' and `code' to produce
  258. old-format databases.  The old format differs from the new one in the
  259. following ways.  Instead of each entry starting with an
  260. offset-differential count byte and ending with a null, byte values from
  261. 0 through 28 indicate offset-differential counts from -14 through 14.
  262. The byte value indicating that a long offset-differential count follows
  263. is 0x1e (30), not 0x80.  The long counts are stored in host byte order,
  264. which is not necessarily network byte order, and host integer word size,
  265. which is usually 4 bytes.  They also represent a count 14 less than
  266. their value.  The database lines have no termination byte; the start of
  267. the next line is indicated by its first byte having a value <= 30.
  268.    In addition, instead of starting with a dummy entry, the old database
  269. format starts with a 256 byte table containing the 128 most common
  270. bigrams in the file list.  A bigram is a pair of adjacent bytes.  Bytes
  271. in the database that have the high bit set are indexes (with the high
  272. bit cleared) into the bigram table.  The bigram and offset-differential
  273. count coding makes these databases 20-25% smaller than the new format,
  274. but makes them not 8-bit clean.  Any byte in a file name that is in the
  275. ranges used for the special codes is replaced in the database by a
  276. question mark, which not coincidentally is the shell wildcard to match a
  277. single character.
  278. File: find.info,  Node: File Permissions,  Next: Reference,  Prev: Databases,  Up: Top
  279. File Permissions
  280. ****************
  281.    Each file has a set of "permissions" that control the kinds of
  282. access that users have to that file.  The permissions for a file are
  283. also called its "access mode".  They can be represented either in
  284. symbolic form or as an octal number.
  285. * Menu:
  286. * Mode Structure::              Structure of file permissions.
  287. * Symbolic Modes::              Mnemonic permissions representation.
  288. * Numeric Modes::               Permissions as octal numbers.
  289. File: find.info,  Node: Mode Structure,  Next: Symbolic Modes,  Up: File Permissions
  290. Structure of File Permissions
  291. =============================
  292.    There are three kinds of permissions that a user can have for a file:
  293.   1. permission to read the file.  For directories, this means
  294.      permission to list the contents of the directory.
  295.   2. permission to write to (change) the file.  For directories, this
  296.      means permission to create and remove files in the directory.
  297.   3. permission to execute the file (run it as a program).  For
  298.      directories, this means permission to access files in the
  299.      directory.
  300.    There are three categories of users who may have different
  301. permissions to perform any of the above operations on a file:
  302.   1. the file's owner;
  303.   2. other users who are in the file's group;
  304.   3. everyone else.
  305.    Files are given an owner and group when they are created.  Usually
  306. the owner is the current user and the group is the group of the
  307. directory the file is in, but this varies with the operating system, the
  308. filesystem the file is created on, and the way the file is created.  You
  309. can change the owner and group of a file by using the `chown' and
  310. `chgrp' commands.
  311.    In addition to the three sets of three permissions listed above, a
  312. file's permissions have three special components, which affect only
  313. executable files (programs) and, on some systems, directories:
  314.   1. set the process's effective user ID to that of the file upon
  315.      execution (called the "setuid bit").  No effect on directories.
  316.   2. set the process's effective group ID to that of the file upon
  317.      execution (called the "setgid bit").  For directories on some
  318.      systems, put files created in the directory into the same group as
  319.      the directory, no matter what group the user who creates them is
  320.      in.
  321.   3. save the program's text image on the swap device so it will load
  322.      more quickly when run (called the "sticky bit").  For directories
  323.      on some systems, prevent users from removing files that they do
  324.      not own in the directory; this is called making the directory
  325.      "append-only".
  326. File: find.info,  Node: Symbolic Modes,  Next: Numeric Modes,  Prev: Mode Structure,  Up: File Permissions
  327. Symbolic Modes
  328. ==============
  329.    "Symbolic modes" represent changes to files' permissions as
  330. operations on single-character symbols.  They allow you to modify either
  331. all or selected parts of files' permissions, optionally based on their
  332. previous values, and perhaps on the current `umask' as well (*note
  333. Umask and Protection::.).
  334.    The format of symbolic modes is:
  335.      [ugoa...][[+-=][rwxXstugo...]...][,...]
  336.    The following sections describe the operators and other details of
  337. symbolic modes.
  338. * Menu:
  339. * Setting Permissions::          Basic operations on permissions.
  340. * Copying Permissions::          Copying existing permissions.
  341. * Changing Special Permissions:: Special permissions.
  342. * Conditional Executability::    Conditionally affecting executability.
  343. * Multiple Changes::             Making multiple changes.
  344. * Umask and Protection::              The effect of the umask.
  345. File: find.info,  Node: Setting Permissions,  Next: Copying Permissions,  Up: Symbolic Modes
  346. Setting Permissions
  347. -------------------
  348.    The basic symbolic operations on a file's permissions are adding,
  349. removing, and setting the permission that certain users have to read,
  350. write, and execute the file.  These operations have the following
  351. format:
  352.      USERS OPERATION PERMISSIONS
  353. The spaces between the three parts above are shown for readability only;
  354. symbolic modes can not contain spaces.
  355.    The USERS part tells which users' access to the file is changed.  It
  356. consists of one or more of the following letters (or it can be empty;
  357. *note Umask and Protection::., for a description of what happens then).
  358. When more than one of these letters is given, the order that they are
  359. in does not matter.
  360.      the user who owns the file;
  361.      other users who are in the file's group;
  362.      all other users;
  363.      all users; the same as `ugo'.
  364.    The OPERATION part tells how to change the affected users' access to
  365. the file, and is one of the following symbols:
  366.      to add the PERMISSIONS to whatever permissions the USERS already
  367.      have for the file;
  368.      to remove the PERMISSIONS from whatever permissions the USERS
  369.      already have for the file;
  370.      to make the PERMISSIONS the only permissions that the USERS have
  371.      for the file.
  372.    The PERMISSIONS part tells what kind of access to the file should be
  373. changed; it is zero or more of the following letters.  As with the
  374. USERS part, the order does not matter when more than one letter is
  375. given.  Omitting the PERMISSIONS part is useful only with the `='
  376. operation, where it gives the specified USERS no access at all to the
  377. file.
  378.      the permission the USERS have to read the file;
  379.      the permission the USERS have to write to the file;
  380.      the permission the USERS have to execute the file.
  381.    For example, to give everyone permission to read and write a file,
  382. but not to execute it, use:
  383.      a=rw
  384.    To remove write permission for from all users other than the file's
  385. owner, use:
  386.      go-w
  387. The above command does not affect the access that the owner of the file
  388. has to it, nor does it affect whether other users can read or execute
  389. the file.
  390.    To give everyone except a file's owner no permission to do anything
  391. with that file, use the mode below.  Other users could still remove the
  392. file, if they have write permission on the directory it is in.
  393.      go=
  394. Another way to specify the same thing is:
  395.      og-rxw
  396. File: find.info,  Node: Copying Permissions,  Next: Changing Special Permissions,  Prev: Setting Permissions,  Up: Symbolic Modes
  397. Copying Existing Permissions
  398. ----------------------------
  399.    You can base part of a file's permissions on part of its existing
  400. permissions.  To do this, instead of using `r', `w', or `x' after the
  401. operator, you use the letter `u', `g', or `o'.  For example, the mode
  402.      o+g
  403. adds the permissions for users who are in a file's group to the
  404. permissions that other users have for the file.  Thus, if the file
  405. started out as mode 664 (`rw-rw-r--'), the above mode would change it
  406. to mode 666 (`rw-rw-rw-').  If the file had started out as mode 741
  407. (`rwxr----x'), the above mode would change it to mode 745
  408. (`rwxr--r-x').  The `-' and `=' operations work analogously.
  409. File: find.info,  Node: Changing Special Permissions,  Next: Conditional Executability,  Prev: Copying Permissions,  Up: Symbolic Modes
  410. Changing Special Permissions
  411. ----------------------------
  412.    In addition to changing a file's read, write, and execute
  413. permissions, you can change its special permissions.  *Note Mode
  414. Structure::, for a summary of these permissions.
  415.    To change a file's permission to set the user ID on execution, use
  416. `u' in the USERS part of the symbolic mode and `s' in the PERMISSIONS
  417. part.
  418.    To change a file's permission to set the group ID on execution, use
  419. `g' in the USERS part of the symbolic mode and `s' in the PERMISSIONS
  420. part.
  421.    To change a file's permission to stay permanently on the swap device,
  422. use `o' in the USERS part of the symbolic mode and `t' in the
  423. PERMISSIONS part.
  424.    For example, to add set user ID permission to a program, you can use
  425. the mode:
  426.      u+s
  427.    To remove both set user ID and set group ID permission from it, you
  428. can use the mode:
  429.      ug-s
  430.    To cause a program to be saved on the swap device, you can use the
  431. mode:
  432.      o+t
  433.    Remember that the special permissions only affect files that are
  434. executable, plus, on some systems, directories (on which they have
  435. different meanings; *note Mode Structure::.).  Using `a' in the USERS
  436. part of a symbolic mode does not cause the special permissions to be
  437. affected; thus,
  438.      a+s
  439. has *no effect*.  You must use `u', `g', and `o' explicitly to affect
  440. the special permissions.  Also, the combinations `u+t', `g+t', and
  441. `o+s' have no effect.
  442.    The `=' operator is not very useful with special permissions; for
  443. example, the mode:
  444.      o=t
  445. does cause the file to be saved on the swap device, but it also removes
  446. all read, write, and execute permissions that users not in the file's
  447. group might have had for it.
  448. File: find.info,  Node: Conditional Executability,  Next: Multiple Changes,  Prev: Changing Special Permissions,  Up: Symbolic Modes
  449. Conditional Executability
  450. -------------------------
  451.    There is one more special type of symbolic permission: if you use
  452. `X' instead of `x', execute permission is affected only if the file
  453. already had execute permission or is a directory.  It affects
  454. directories' execute permission even if they did not initially have any
  455. execute permissions set.
  456.    For example, this mode:
  457.      a+X
  458. gives all users permission to execute files (or search directories) if
  459. anyone could before.
  460. File: find.info,  Node: Multiple Changes,  Next: Umask and Protection,  Prev: Conditional Executability,  Up: Symbolic Modes
  461. Making Multiple Changes
  462. -----------------------
  463.    The format of symbolic modes is actually more complex than described
  464. above (*note Setting Permissions::.).  It provides two ways to make
  465. multiple changes to files' permissions.
  466.    The first way is to specify multiple OPERATION and PERMISSIONS parts
  467. after a USERS part in the symbolic mode.
  468.    For example, the mode:
  469.      og+rX-w
  470. gives users other than the owner of the file read permission and, if it
  471. is a directory or if someone already had execute permission to it,
  472. gives them execute permission; and it also denies them write permission
  473. to it file.  It does not affect the permission that the owner of the
  474. file has for it.  The above mode is equivalent to the two modes:
  475.      og+rX
  476.      og-w
  477.    The second way to make multiple changes is to specify more than one
  478. simple symbolic mode, separated by commas.  For example, the mode:
  479.      a+r,go-w
  480. gives everyone permission to read the file and removes write permission
  481. on it for all users except its owner.  Another example:
  482.      u=rwx,g=rx,o=
  483. sets all of the non-special permissions for the file explicitly.  (It
  484. gives users who are not in the file's group no permission at all for
  485.    The two methods can be combined.  The mode:
  486.      a+r,g+x-w
  487. gives all users permission to read the file, and gives users who are in
  488. the file's group permission to execute it, as well, but not permission
  489. to write to it.  The above mode could be written in several different
  490. ways; another is:
  491.      u+r,g+rx,o+r,g-w
  492. File: find.info,  Node: Umask and Protection,  Prev: Multiple Changes,  Up: Symbolic Modes
  493. The Umask and Protection
  494. ------------------------
  495.    If the USERS part of a symbolic mode is omitted, it defaults to `a'
  496. (affect all users), except that any permissions that are *set* in the
  497. system variable `umask' are *not affected*.  The value of `umask' can
  498. be set using the `umask' command.  Its default value varies from system
  499. to system.
  500.    Omitting the USERS part of a symbolic mode is generally not useful
  501. with operations other than `+'.  It is useful with `+' because it
  502. allows you to use `umask' as an easily customizable protection against
  503. giving away more permission to files than you intended to.
  504.    As an example, if `umask' has the value 2, which removes write
  505. permission for users who are not in the file's group, then the mode:
  506.      +w
  507. adds permission to write to the file to its owner and to other users who
  508. are in the file's group, but *not* to other users.  In contrast, the
  509. mode:
  510.      a+w
  511. ignores `umask', and *does* give write permission for the file to all
  512. users.
  513. File: find.info,  Node: Numeric Modes,  Prev: Symbolic Modes,  Up: File Permissions
  514. Numeric Modes
  515. =============
  516.    File permissions are stored internally as 16 bit integers.  As an
  517. alternative to giving a symbolic mode, you can give an octal (base 8)
  518. number that corresponds to the internal representation of the new mode.
  519. This number is always interpreted in octal; you do not have to add a
  520. leading 0, as you do in C.  Mode 0055 is the same as mode 55.
  521.    A numeric mode is usually shorter than the corresponding symbolic
  522. mode, but it is limited in that it can not take into account a file's
  523. previous permissions; it can only set them absolutely.
  524.    The permissions granted to the user, to other users in the file's
  525. group, and to other users not in the file's group are each stored as
  526. three bits, which are represented as one octal digit.  The three special
  527. permissions are also each stored as one bit, and they are as a group
  528. represented as another octal digit.  Here is how the bits are arranged
  529. in the 16 bit integer, starting with the lowest valued bit:
  530.      Value in  Corresponding
  531.      Mode      Permission
  532.      
  533.                Other users not in the file's group:
  534.         1      Execute
  535.         2      Write
  536.         4      Read
  537.      
  538.                Other users in the file's group:
  539.        10      Execute
  540.        20      Write
  541.        40      Read
  542.      
  543.                The file's owner:
  544.       100      Execute
  545.       200      Write
  546.       400      Read
  547.      
  548.                Special permissions:
  549.      1000      Save text image on swap device
  550.      2000      Set group ID on execution
  551.      4000      Set user ID on execution
  552.    For example, numeric mode 4755 corresponds to symbolic mode
  553. `u=rwxs,go=rx', and numeric mode 664 corresponds to symbolic mode
  554. `ug=rw,o=r'.  Numeric mode 0 corresponds to symbolic mode `ugo='.
  555. File: find.info,  Node: Reference,  Next: Primary Index,  Prev: File Permissions,  Up: Top
  556. Reference
  557. *********
  558.    Below are summaries of the command line syntax for the programs
  559. discussed in this manual.
  560. * Menu:
  561. * Invoking find::
  562. * Invoking locate::
  563. * Invoking updatedb::
  564. * Invoking xargs::
  565. File: find.info,  Node: Invoking find,  Next: Invoking locate,  Up: Reference
  566. Invoking `find'
  567. ===============
  568.      find [FILE...] [EXPRESSION]
  569.    `find' searches the directory tree rooted at each file name FILE by
  570. evaluating the EXPRESSION on each file it finds in the tree.
  571.    `find' considers the first argument that begins with `-', `(', `)',
  572. `,', or `!' to be the beginning of the expression; any arguments before
  573. it are paths to search, and any arguments after it are the rest of the
  574. expression.  If no paths are given, the current directory is used.  If
  575. no expression is given, the expression `-print' is used.
  576.    `find' exits with status 0 if all files are processed successfully,
  577. greater than 0 if errors occur.
  578.    *Note Primary Index::, for a summary of all of the tests, actions,
  579. and options that the expression can contain.
  580.    `find' also recognizes two options for administrative use:
  581. `--help'
  582.      Print a summary of the command-line argument format and exit.
  583. `--version'
  584.      Print the version number of `find' and exit.
  585. File: find.info,  Node: Invoking locate,  Next: Invoking updatedb,  Prev: Invoking find,  Up: Reference
  586. Invoking `locate'
  587. =================
  588.      locate [OPTION...] PATTERN...
  589. `--database=PATH'
  590. `-d PATH'
  591.      Instead of searching the default file name database, search the
  592.      file name databases in PATH, which is a colon-separated list of
  593.      database file names.  You can also use the environment variable
  594.      `LOCATE_PATH' to set the list of database files to search.  The
  595.      option overrides the environment variable if both are used.
  596. `--help'
  597.      Print a summary of the options to `locate' and exit.
  598. `--version'
  599.      Print the version number of `locate' and exit.
  600. File: find.info,  Node: Invoking updatedb,  Next: Invoking xargs,  Prev: Invoking locate,  Up: Reference
  601. Invoking `updatedb'
  602. ===================
  603.      updatedb [OPTION...]
  604. `--localpaths='PATH...''
  605.      Non-network directories to put in the database.  Default is `/'.
  606. `--netpaths='PATH...''
  607.      Network (NFS, AFS, RFS, etc.) directories to put in the database.
  608.      Default is none.
  609. `--prunepaths='PATH...''
  610.      Directories to not put in the database, which would otherwise be.
  611.      Default is `/tmp /usr/tmp /var/tmp /afs'.
  612. `--output=DBFILE'
  613.      The database file to build.  Default is system-dependent, but
  614.      typically `/usr/local/var/locatedb'.
  615. `--netuser=USER'
  616.      The user to search network directories as, using `su'(1).  Default
  617.      is `daemon'.
  618. File: find.info,  Node: Invoking xargs,  Prev: Invoking updatedb,  Up: Reference
  619. Invoking `xargs'
  620. ================
  621.      xargs [OPTION...] [COMMAND [INITIAL-ARGUMENTS]]
  622.    `xargs' exits with the following status:
  623.      if it succeeds
  624.      if any invocation of the command exited with status 1-125
  625.      if the command exited with status 255
  626.      if the command is killed by a signal
  627.      if the command cannot be run
  628.      if the command is not found
  629.      if some other error occurred.
  630. `--null'
  631.      Input filenames are terminated by a null character instead of by
  632.      whitespace, and the quotes and backslash are not special (every
  633.      character is taken literally).  Disables the end of file string,
  634.      which is treated like any other argument.
  635. `--eof[=EOF-STR]'
  636. `-e[EOF-STR]'
  637.      Set the end of file string to EOF-STR.  If the end of file string
  638.      occurs as a line of input, the rest of the input is ignored.  If
  639.      EOF-STR is omitted, there is no end of file string.  If this
  640.      option is not given, the end of file string defaults to `_'.
  641. `--help'
  642.      Print a summary of the options to `xargs' and exit.
  643. `--replace[=REPLACE-STR]'
  644. `-i[REPLACE-STR]'
  645.      Replace occurences of REPLACE-STR in the initial arguments with
  646.      names read from standard input.  Also, unquoted blanks do not
  647.      terminate arguments.  If REPLACE-STR is omitted, it defaults to
  648.      `{}' (like for `find -exec').  Implies `-x' and `-l 1'.
  649. `--max-lines[=MAX-LINES]'
  650. `-l[MAX-LINES]'
  651.      Use at most MAX-LINES nonblank input lines per command line;
  652.      MAX-LINES defaults to 1 if omitted.  Trailing blanks cause an
  653.      input line to be logically continued on the next input line, for
  654.      the purpose of counting the lines.  Implies `-x'.
  655. `--max-args=MAX-ARGS'
  656. `-n MAX-ARGS'
  657.      Use at most MAX-ARGS arguments per command line.  Fewer than
  658.      MAX-ARGS arguments will be used if the size (see the `-s' option)
  659.      is exceeded, unless the `-x' option is given, in which case
  660.      `xargs' will exit.
  661. `--interactive'
  662.      Prompt the user about whether to run each command line and read a
  663.      line from the terminal.  Only run the command line if the response
  664.      starts with `y' or `Y'.  Implies `-t'.
  665. `--no-run-if-empty'
  666.      If the standard input does not contain any nonblanks, do not run
  667.      the command.  By default, the command is run once even if there is
  668.      no input.
  669. `--max-chars=MAX-CHARS'
  670. `-s MAX-CHARS'
  671.      Use at most MAX-CHARS characters per command line, including the
  672.      command and initial arguments and the terminating nulls at the
  673.      ends of the argument strings.
  674. `--verbose'
  675.      Print the command line on the standard error output before
  676.      executing it.
  677. `--version'
  678.      Print the version number of `xargs' and exit.
  679. `--exit'
  680.      Exit if the size (see the -S option) is exceeded.
  681. `--max-procs=MAX-PROCS'
  682. `-P MAX-PROCS'
  683.      Run up to MAX-PROCS processes at a time; the default is 1.  If
  684.      MAX-PROCS is 0, `xargs' will run as many processes as possible at
  685.      a time.
  686. File: find.info,  Node: Primary Index,  Prev: Reference,  Up: Top
  687. `find' Primary Index
  688. ********************
  689.    This is a list of all of the primaries (tests, actions, and options)
  690. that make up `find' expressions for selecting files.  *Note find
  691. Expressions::, for more information on expressions.
  692. * Menu:
  693. * -amin:                                Age Ranges.
  694. * -anewer:                              Comparing Timestamps.
  695. * -atime:                               Age Ranges.
  696. * -cmin:                                Age Ranges.
  697. * -cnewer:                              Comparing Timestamps.
  698. * -ctime:                               Age Ranges.
  699. * -daystart:                            Age Ranges.
  700. * -depth:                               Directories.
  701. * -empty:                               Size.
  702. * -exec:                                Single File.
  703. * -false:                               Combining Primaries With Operators.
  704. * -fls:                                 Print File Information.
  705. * -follow:                              Symbolic Links.
  706. * -fprint:                              Print File Name.
  707. * -fprint0:                             Safe File Name Handling.
  708. * -fprintf:                             Print File Information.
  709. * -fstype:                              Filesystems.
  710. * -gid:                                 Owner.
  711. * -group:                               Owner.
  712. * -ilname:                              Symbolic Links.
  713. * -iname:                               Base Name Patterns.
  714. * -inum:                                Hard Links.
  715. * -ipath:                               Full Name Patterns.
  716. * -iregex:                              Full Name Patterns.
  717. * -links:                               Hard Links.
  718. * -lname:                               Symbolic Links.
  719. * -ls:                                  Print File Information.
  720. * -maxdepth:                            Directories.
  721. * -mindepth:                            Directories.
  722. * -mmin:                                Age Ranges.
  723. * -mount:                               Filesystems.
  724. * -mtime:                               Age Ranges.
  725. * -name:                                Base Name Patterns.
  726. * -newer:                               Comparing Timestamps.
  727. * -nogroup:                             Owner.
  728. * -noleaf:                              Directories.
  729. * -nouser:                              Owner.
  730. * -ok:                                  Querying.
  731. * -path:                                Full Name Patterns.
  732. * -perm:                                Permissions.
  733. * -print:                               Print File Name.
  734. * -print0:                              Safe File Name Handling.
  735. * -printf:                              Print File Information.
  736. * -prune:                               Directories.
  737. * -regex:                               Full Name Patterns.
  738. * -size:                                Size.
  739. * -true:                                Combining Primaries With Operators.
  740. * -type:                                Type.
  741. * -uid:                                 Owner.
  742. * -used:                                Comparing Timestamps.
  743. * -user:                                Owner.
  744. * -xdev:                                Filesystems.
  745. * -xtype:                               Type.
  746.