Debian で破損した権限を修正する方法

Debian で破損した権限を修正する方法

私のDebian 11システムには、明らかに権限のないフォルダがあります。ルートとして、フォルダはユーザーansible(所有者)に属し、正しい権限セット(0644)を持っているため、ユーザーがファイルを簡単に表示できることがわかります。

ansible@BACKUP:~$ sudo -s
root@BACKUP:/home/ansible# cd /opt/docker/config/opensearch/
root@BACKUP:/opt/docker/config/opensearch# ls -al
total 32
drw-r--r-- 3 ansible root  4096 Jun  8 15:38 .
drwxr-xr-x 7 ansible root  4096 Jun  8 13:28 ..
drw-r--r-- 2 ansible root  4096 Jun  8 14:14 certs
-rw-r--r-- 1 ansible root 14150 Jun  8 15:38 custom-opensearch.yml
-rw-r--r-- 1 ansible root   536 Jun  8 13:28 internal_users.yml

ユーザーはansibleに戻りますが、フォルダにアクセスできません。

ansible@BACKUP:~$ whoami
ansible
ansible@BACKUP:~$ cd /opt/docker/config/opensearch/
-bash: cd: /opt/docker/config/opensearch/: Permission denied

また、ディレクトリを一覧表示しようとするとファイル名を見ることができるという点で奇妙な出力が表示されますが、それはすべてです。

ansible@BACKUP:~$ ls -al /opt/docker/config/opensearch/
ls: cannot access '/opt/docker/config/opensearch/custom-opensearch.yml': Permission denied
ls: cannot access '/opt/docker/config/opensearch/certs': Permission denied
ls: cannot access '/opt/docker/config/opensearch/.': Permission denied
ls: cannot access '/opt/docker/config/opensearch/internal_users.yml': Permission denied
ls: cannot access '/opt/docker/config/opensearch/..': Permission denied
total 0
d????????? ? ? ? ?            ? .
d????????? ? ? ? ?            ? ..
d????????? ? ? ? ?            ? certs
-????????? ? ? ? ?            ? custom-opensearch.yml
-????????? ? ? ? ?            ? internal_users.yml

オペレーティングシステムのバージョン:

ansible@BACKUP:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 11 (bullseye)
Release:        11
Codename:       bullseye

これらの権限を変更するにはどうすればよいですか?一般的な容疑者をrootとして試しました。

root@BACKUP:/home/ansible# chown -R ansible:root /opt/docker/config/opensearch/
root@BACKUP:/home/ansible# chmod -R 0644 /opt/docker/config/opensearch/

これらの間に違いはありません。

//編集1:ls -alZ出力を追加

root@BACKUP:/opt/docker/config/opensearch# ls -laZ
total 36
drw-r--r-- 3 ansible root ?  4096 Jun  8 15:59 .
drwxr-xr-x 7 ansible root ?  4096 Jun  8 13:28 ..
drw-r--r-- 2 ansible root ?  4096 Jun  8 14:14 certs
-rw-r--r-- 1 root    root ?   399 Jun  8 15:59 config.yml
-rw-r--r-- 1 ansible root ? 14150 Jun  8 15:38 custom-opensearch.yml
-rw-r--r-- 1 ansible root ?   536 Jun  8 13:28 internal_users.yml

ベストアンサー1

理由は次のとおりです。

root@BACKUP:/opt/docker/config/opensearch# ls -al
total 32
drw-r--r-- 3 ansible root  4096 Jun  8 15:38 .  <--- 'x' permissions missing
drwxr-xr-x 7 ansible root  4096 Jun  8 13:28 ..
drw-r--r-- 2 ansible root  4096 Jun  8 14:14 certs  <--- 'x' permissions missing

ディレクトリとディレクトリにx権限がありません。/opt/docker/config/opensearchcerts

一般ファイルの場合、x権限は次のことを意味します。実装する。ディレクトリの場合、これは次のことを意味します。コンテンツにアクセスrディレクトリに対する権限がないと、xその中のファイルとサブディレクトリの名前を読み取ることができますが、それに関連するメタデータは読み取れません。その結果、対応するls -lディレクトリのリストは次のようになります。

d????????? ? ? ? ?            ? .
d????????? ? ? ? ?            ? ..
d????????? ? ? ? ?            ? certs
-????????? ? ? ? ?            ? custom-opensearch.yml
-????????? ? ? ? ?            ? internal_users.yml

技術的には、ファイル名はディレクトリ自体の一部なので表示できますが、アクセス権がないためインデックスノードファイルとサブディレクトリを表すと、所有権/権限/タイムスタンプ/サイズ情報を表示できません。

修理する:

chmod a+x /opt/docker/config/opensearch /opt/docker/config/opensearch/certs

x場合によっては、権限はあるが権限はないディレクトリを持つことが望ましい場合がありますr。したがって、ユーザーは、アクセスする必要があるファイルまたはサブディレクトリの正確な名前を事前に知っている場合にのみ、その中のファイルにアクセスできます。しかし、その逆の場合、r権限はあるがその権限がないディレクトリx(私が知る限り)は、一般的な使用には実際には役に立ちません。

おすすめ記事