私が実行した場合(sudoを使用して)
sudo find / -xdev -type f ! -path '/home/blueray/*' ! -path '/timeshift/*' > log.txt
何の問題もなくうまくいきます。
ただし、sudoなしで同じコマンドを実行すると、コンソールでいくつかのエラーが発生します。検索結果log.txt
が正しい(問題なし)。しかし、エラーメッセージを理解していません。
% find / -xdev -type f ! -path '/home/blueray/*' ! -path '/timeshift/*' > log.txt
find: ‘/timeshift/snapshots/2022-01-09_22-00-46/localhost/etc/polkit-1/localauthority’: Permission denied
find: ‘/timeshift/snapshots/2022-01-09_22-00-46/localhost/etc/ssl/private’: Permission denied
find: ‘/timeshift/snapshots/2022-01-09_22-00-46/localhost/etc/cups/ssl’: Permission denied
find: ‘/timeshift/snapshots/2022-01-09_22-00-46/localhost/var/log/private’: Permission denied
find: ‘/timeshift/snapshots/2022-01-09_22-00-46/localhost/var/log/speech-dispatcher’: Permission denied
find: ‘/timeshift/snapshots/2022-01-09_22-00-46/localhost/var/spool/rsyslog’: Permission denied
find: ‘/timeshift/snapshots/2022-01-09_22-00-46/localhost/var/spool/cups’: Permission denied
find: ‘/timeshift/snapshots/2022-01-09_22-00-46/localhost/var/spool/cron/crontabs’: Permission denied
find: ‘/timeshift/snapshots/2022-01-09_22-00-46/localhost/var/lib/apt/lists/partial’: Permission denied
find: ‘/timeshift/snapshots/2022-01-09_22-00-46/localhost/var/lib/colord/.cache’: Permission denied
find: ‘/timeshift/snapshots/2022-01-09_22-00-46/localhost/var/lib/AccountsService/users’: Permission denied
find: ‘/timeshift/snapshots/2022-01-09_22-00-46/localhost/var/lib/bluetooth/5C:F3:70:93:BD:85’: Permission denied
find: ‘/timeshift/snapshots/2022-01-09_22-00-46/localhost/var/lib/lightdm-data/lightdm’: Permission denied
find: ‘/timeshift/snapshots/2022-01-09_22-00-46/localhost/var/lib/polkit-1’: Permission denied
find: ‘/timeshift/snapshots/2022-01-09_22-00-46/localhost/var/lib/udisks2’: Permission denied
find: ‘/timeshift/snapshots/2022-01-09_22-00-46/localhost/var/lib/NetworkManager’: Permission denied
find: ‘/timeshift/snapshots/2022-01-09_22-00-46/localhost/var/lib/private’: Permission denied
find: ‘/timeshift/snapshots/2022-01-09_22-00-46/localhost/var/lib/lightdm’: Permission denied
find: ‘/timeshift/snapshots/2022-01-09_22-00-46/localhost/var/lib/tor’: Permission denied
find: ‘/timeshift/snapshots/2022-01-09_22-00-46/localhost/var/cache/private’: Permission denied
find: ‘/timeshift/snapshots/2022-01-09_22-00-46/localhost/var/cache/apparmor/26b63962.0’: Permission denied
find: ‘/timeshift/snapshots/2022-01-09_22-00-46/localhost/var/cache/lightdm/dmrc’: Permission denied
find: ‘/timeshift/snapshots/2022-01-09_22-00-46/localhost/var/cache/cups’: Permission denied
find: ‘/timeshift/snapshots/2022-01-09_22-00-46/localhost/var/cache/ldconfig’: Permission denied
find: ‘/timeshift/snapshots/2022-01-09_22-00-46/localhost/var/tmp/systemd-private-84c1e6e852b747ea9d34d17ca664b32b-tor@default.service-frAbZe’: Permission denied
find: ‘/timeshift/snapshots/2022-01-09_22-00-46/localhost/var/tmp/systemd-private-84c1e6e852b747ea9d34d17ca664b32b-systemd-logind.service-EWXwaj’: Permission denied
find: ‘/timeshift/snapshots/2022-01-09_22-00-46/localhost/var/tmp/systemd-private-84c1e6e852b747ea9d34d17ca664b32b-ModemManager.service-0wY2Hh’: Permission denied
find: ‘/timeshift/snapshots/2022-01-09_22-00-46/localhost/var/tmp/systemd-private-84c1e6e852b747ea9d34d17ca664b32b-colord.service-HLWVQf’: Permission denied
find: ‘/timeshift/snapshots/2022-01-09_22-00-46/localhost/var/tmp/systemd-private-84c1e6e852b747ea9d34d17ca664b32b-upower.service-ecD4ii’: Permission denied
find: ‘/timeshift/snapshots/2022-01-09_22-00-46/localhost/var/tmp/systemd-private-84c1e6e852b747ea9d34d17ca664b32b-systemd-resolved.service-Qxjpij’: Permission denied
find: ‘/timeshift/snapshots/2022-01-09_22-00-46/localhost/var/tmp/systemd-private-84c1e6e852b747ea9d34d17ca664b32b-systemd-timesyncd.service-Kf61Zi’: Permission denied
find: ‘/timeshift/snapshots/2022-01-09_22-00-46/localhost/root’: Permission denied
find: ‘/timeshift/snapshots/2022-01-09_22-00-46/localhost/boot/efi’: Permission denied
find: ‘/etc/libvirt/secrets’: Permission denied
find: ‘/etc/polkit-1/localauthority’: Permission denied
find: ‘/etc/ssl/private’: Permission denied
find: ‘/etc/cups/ssl’: Permission denied
find: ‘/var/log/private’: Permission denied
find: ‘/var/log/speech-dispatcher’: Permission denied
find: ‘/var/spool/rsyslog’: Permission denied
find: ‘/var/spool/cups’: Permission denied
find: ‘/var/spool/cron/crontabs’: Permission denied
find: ‘/var/lib/apt/lists/partial’: Permission denied
find: ‘/var/lib/colord/.cache’: Permission denied
find: ‘/var/lib/AccountsService/users’: Permission denied
find: ‘/var/lib/portables’: Permission denied
find: ‘/var/lib/libvirt/qemu’: Permission denied
find: ‘/var/lib/machines’: Permission denied
find: ‘/var/lib/bluetooth/5C:F3:70:93:BD:85’: Permission denied
find: ‘/var/lib/lightdm-data/lightdm’: Permission denied
find: ‘/var/lib/polkit-1’: Permission denied
find: ‘/var/lib/udisks2’: Permission denied
find: ‘/var/lib/NetworkManager’: Permission denied
find: ‘/var/lib/private’: Permission denied
find: ‘/var/lib/lightdm’: Permission denied
find: ‘/var/lib/tor’: Permission denied
find: ‘/var/lib/fwupd/gnupg’: Permission denied
find: ‘/var/cache/apt/archives/partial’: Permission denied
find: ‘/var/cache/private’: Permission denied
find: ‘/var/cache/apparmor/26b63962.0’: Permission denied
find: ‘/var/cache/lightdm/dmrc’: Permission denied
find: ‘/var/cache/cups’: Permission denied
find: ‘/var/cache/ldconfig’: Permission denied
find: ‘/var/tmp/systemd-private-c9d7a83d6f844d998e8423d94d48ce3f-ModemManager.service-G72K7i’: Permission denied
find: ‘/var/tmp/systemd-private-c9d7a83d6f844d998e8423d94d48ce3f-colord.service-2B8Ofg’: Permission denied
find: ‘/var/tmp/systemd-private-c9d7a83d6f844d998e8423d94d48ce3f-tor@default.service-TaP1xi’: Permission denied
find: ‘/var/tmp/systemd-private-c9d7a83d6f844d998e8423d94d48ce3f-systemd-logind.service-rnYjPi’: Permission denied
find: ‘/var/tmp/systemd-private-c9d7a83d6f844d998e8423d94d48ce3f-systemd-timesyncd.service-U7G6Lf’: Permission denied
find: ‘/var/tmp/systemd-private-c9d7a83d6f844d998e8423d94d48ce3f-systemd-resolved.service-ABf5Xe’: Permission denied
find: ‘/var/tmp/systemd-private-c9d7a83d6f844d998e8423d94d48ce3f-upower.service-WW9yYi’: Permission denied
find: ‘/root’: Permission denied
find: ‘/lost+found’: Permission denied
find: ‘/tmp/systemd-private-c9d7a83d6f844d998e8423d94d48ce3f-upower.service-F7Rtjf’: Permission denied
find: ‘/tmp/systemd-private-c9d7a83d6f844d998e8423d94d48ce3f-tor@default.service-nYCXFi’: Permission denied
find: ‘/tmp/systemd-private-c9d7a83d6f844d998e8423d94d48ce3f-colord.service-qGi0sf’: Permission denied
find: ‘/tmp/systemd-private-c9d7a83d6f844d998e8423d94d48ce3f-systemd-logind.service-FhyyUh’: Permission denied
find: ‘/tmp/systemd-private-c9d7a83d6f844d998e8423d94d48ce3f-systemd-resolved.service-luOB7f’: Permission denied
find: ‘/tmp/systemd-private-c9d7a83d6f844d998e8423d94d48ce3f-ModemManager.service-d1MZ7g’: Permission denied
find: ‘/tmp/systemd-private-c9d7a83d6f844d998e8423d94d48ce3f-systemd-timesyncd.service-79KkRe’: Permission denied
findコマンドで使用したのに、find: ‘/timeshift/snapshots/....’: Permission denied
なぜこのように表示されますか?! -path '/timeshift/*'
私の常識によると、findコマンドは検索から除外されたディレクトリの権限を気にする必要はありません。
それでは、正確に何が起こっているのか、sudoを使用せずにこれらのエラーメッセージを削除する方法は何ですか?私の言葉は、findコマンドに「除外後の検索」またはそれに類似することを意味する位置引数があるということです。
答え1
を使用すると、-path
現在のパス名がパターンと一致するかどうかをテストし、それを除外または処理し続けることができます。find
サブディレクトリに入るのをやめません。
検索ツリーをクリーンアップするには(検索からディレクトリを削除する)を使用します-prune
。
find / -xdev \
\( -path '/home/blueray' -o -path '/timeshift' \) -prune -o \
-type f -print
これにより、両方のテストのいずれかに一致するパスが切り捨てられ、通常の-path
ファイルに対応する他のすべてのパス名が出力されます。切り捨てられたパスは入力されていないため、上記のfind
コマンド/home/blueray
または下のすべての項目は/timeshift
考慮されませんfind
。