从 Ubuntu 19.04 升级到 19.10 后,updatedb 实用程序发生了变化(呃,为什么?)。这破坏了我使用旧命令行选项的一些脚本。新系统的新手册页不足以说明新选项应该是什么。
作为参考,旧的命令行是这样的(取自https://www.commandlinux.com/man-page/man8/updatedb.8.html我猜测这是旧版本,因为我现在无法从 19.10 上的 man 实用程序中找到旧版本的手册页):
NAME
updatedb - update a database for mlocate
SYNOPSIS
updatedb [OPTION]...
DESCRIPTION
updatedb creates or updates a database used by locate(1). If the database already exists, its data is reused to avoid rereading directories that have not changed.
updatedb is usually run daily by cron(8) to update the default database.
EXIT STATUS
updatedb returns with exit status 0 on success, 1 on error.
OPTIONS
The PRUNE_BIND_MOUNTS, PRUNEFS, PRUNENAMES and PRUNEPATHS variables, which are modified by some of the options, are documented in detail in updatedb.conf(5).
-f, --add-prunefs FS
Add entries in white-space-separated list FS to PRUNEFS.
-n, --add-prunenames NAMES
Add entries in white-space-separated list NAMES to PRUNENAMES.
-e, --add-prunepaths PATHS
Add entries in white-space-separated list PATHS to PRUNEPATHS.
-U, --database-root PATH
Store only results of scanning the file system subtree rooted at PATH to the generated database. The whole file system is scanned by default.
locate(1) outputs entries as absolute path names which don't contain symbolic links, regardless of the form of PATH.
--debug-pruning
Write debugging information about pruning decisions to standard error output.
-h, --help
Write a summary of the available options to standard output and exit successfully.
-o, --output FILE
Write the database to FILE instead of using the default database.
--prune-bind-mounts FLAG
Set PRUNE_BIND_MOUNTS to FLAG, overriding the configuration file.
--prunefs FS
Set PRUNEFS to FS, overriding the configuration file.
--prunenames NAMES
Set PRUNENAMES to NAMES, overriding the configuration file.
--prunepaths PATHS
Set PRUNEPATHS to PATHS, overriding the configuration file.
-l, --require-visibility FLAG
Set the ``require file visibility before reporting it'' flag in the generated database to FLAG.
If FLAG is 0 or no, or if the database file is readable by "others" or it is not owned by mlocate, locate(1) outputs the database entries even if the user running locate(1) could not have read the directory necessary to find out the file described by the database entry.
If FLAG is 1 or yes (the default), locate(1) checks the permissions of parent directories of each entry before reporting it to the invoking user. To make the file existence truly hidden from other users, the database group is set to mlocate and the database permissions prohibit reading the database by users using other means than locate(1), which is set-gid mlocate.
Note that the visibility flag is checked only if the database is owned by mlocate and it is not readable by "others".
-v, --verbose
Output path names of files to standard output, as soon as they are found.
-V, --version
Write information about the version and license of locate on standard output and exit successfully.
EXAMPLES
To create a private mlocate database as an user other than root, run
updatedb -l 0 -o db_file -U source_directory
Note that all users that can read db_file can get the complete list of files in the subtree of source_directory.
FILES
/etc/updatedb.conf
A configuration file. See updatedb.conf(5).
/var/lib/mlocate/mlocate.db
The database updated by default.
SECURITY
Databases built with --require-visibility no allow users to find names of files and directories of other users, which they would not otherwise be able to do.
NOTES
The accompanying locate(1) utility was designed to be compatible to slocate and attempts to be compatible to GNU locate where possible. This is not the case for updatedb.
AUTHOR
Miloslav Trmac <[email protected]>
SEE ALSO
locate(1), mlocate.db(5), updatedb.conf(5)
Ubuntu 19.10 中的新 updatedb 手册页内容如下:
UPDATEDB(1) General Commands Manual UPDATEDB(1)
NAME
updatedb - update a file name database
SYNOPSIS
updatedb [options]
DESCRIPTION
This manual page documents the GNU version of updatedb, which updates file name databases used by GNU locate. The file name databases contain lists of files that were in particular directory
trees when the databases were last updated. The file name of the default database is determined when locate and updatedb are configured and installed. The frequency with which the databases are
updated and the directories for which they contain entries depend on how often updatedb is run, and with which arguments.
In networked environments, it often makes sense to build a database at the root of each filesystem, containing the entries for that filesystem. updatedb is then run for each filesystem on the
fileserver where that filesystem is on a local disk, to prevent thrashing the network. Users can select which databases locate searches using an environment variable or command line option; see
locate(1). Databases cannot be concatenated together.
The @samp{LOCATGE02} database format was introduced in GNU findutils version 4.0 in order to allow machines with different byte orderings to share the databases. GNU locate can read both the old
and @samp{LOCATE02} database formats, though support for the old pre-4.0 database format will be removed shortly.
OPTIONS
--findoptions='-option1 -option2...'
Global options to pass on to find. The environment variable FINDOPTIONS also sets this value. Default is none.
--localpaths='path1 path2...'
Non-network directories to put in the database. Default is /.
--netpaths='path1 path2...'
Network (NFS, AFS, RFS, etc.) directories to put in the database. The environment variable NETPATHS also sets this value. Default is none.
--prunepaths='path1 path2...'
Directories to not put in the database, which would otherwise be. Remove any trailing slashes from the path names, otherwise updatedb won´t recognise the paths you want to omit (because
it uses them as regular expression patterns). The environment variable PRUNEPATHS also sets this value. Default is /tmp /usr/tmp /var/tmp /afs.
--prunefs='path...'
File systems to not put in the database, which would otherwise be. Note that files are pruned when a file system is reached; any file system mounted under an undesired file system will be
ignored. The environment variable PRUNEFS also sets this value. Default is nfs NFS proc.
--output=dbfile
The database file to build. Default is system-dependent. In Debian GNU/Linux, the default is /var/cache/locate/locatedb.
--localuser=user
The user to search non-network directories as, using su(1). Default is to search the non-network directories as the current user. You can also use the environment variable LOCALUSER to
set this user.
--netuser=user
The user to search network directories as, using su(1). Default is daemon. You can also use the environment variable NETUSER to set this user.
--dbformat=F
Create the database in format F. The default format is called LOCATE02. Alternatively the slocate format is also supported. When the slocate format is in use, the database produced is
marked as having security level 1. If you want to build a system-wide slocate database, you may want to run updatedb as root.
--version
Print the version number of updatedb and exit.
--help Print a summary of the options to updatedb and exit.
SEE ALSO
find(1), locate(1), locatedb(5), xargs(1)
The full documentation for updatedb is maintained as a Texinfo manual. If the info and updatedb programs are properly installed at your site, the command info updatedb should give you access to
the complete manual.
COPYRIGHT
Copyright © 1994-2019 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
BUGS
The updatedb program correctly handles filenames containing newlines, but only if the system's sort command has a working -z option. If you suspect that locate may need to return filenames con‐
taining newlines, consider using its --null option.
The best way to report a bug is to use the form at https://savannah.gnu.org/bugs/?group=findutils. The reason for this is that you will then be able to track progress in fixing the problem.
Other comments about updatedb(1) and about the findutils package in general can be sent to the bug-findutils mailing list. To join the list, send email to [email protected].
UPDATEDB(1)
我当前使用旧版 updatedb 的命令是:
updatedb -l 0 -o /path/to/some/locate.db -U /path/to/some/dir/to/be/scanned
所以我的基本问题是:在哪里使用新版本的 updatedb 指定 /path/to/some/dir/to/be/scanned?
嗯,可能是以下两个选项之一:
--localpaths='path1 path2...'
Non-network directories to put in the database. Default is /.
--netpaths='path1 path2...'
Network (NFS, AFS, RFS, etc.) directories to put in the database. The environment variable NETPATHS also sets this value. Default is none.
但他们没有明确说明“netpath”是什么。我确实有过多次混合运行,其中 /path/to/some/dir/to/be/scanned 是笔记本电脑上的本地目录,而在其他情况下,该目录是网络上 NFS 安装分区上的目录。
答案1
我最终使用的选项是--localpaths
。我暂时放弃了,--netpaths
直到有人可以描述后者的用途。
答案2
我有同样的问题——一些脚本需要进行相应的、不必要的更改。
我最初以为这是locate/update的新版本。但后来我发现这是updatedb/locate的busybox版本,它的功能相同,但方式不同。
我必须安装“mlocate”来解决这个问题!
答案3
在 Ubuntu 20.04 中,如果你想使用sudo updatedb
,你必须先下载mlocate
sudo apt install mlocate
之后只需使用sudo updatedb
。