각 프로젝트의 모든 하위 폴더 .git/에 대해 대량 chmod를 실행합니다.

각 프로젝트의 모든 하위 폴더 .git/에 대해 대량 chmod를 실행합니다.

와 같은 단일 폴더에 대해 CHMOD 방법을 알고 있지만 chmod 700 .git/내 서버에는 여러 프로젝트가 있고 각 프로젝트에는 .git/ 폴더가 포함되어 있습니다. repo-lookout.org 보고서에 따르면 .git/저장소에 대한 액세스를 비활성화할 것을 제안합니다. 모든 폴더에 대량 chmod 700을 적용하고 싶습니다 .git/(그러나 내부 하위 폴더는 포함하지 않음 .git).

실행하면 find */.git/ -type d다음과 같은 목록이 반환됩니다.

site1/.git/objects/b3
site1/.git/info
site1/.git/refs
site1/.git/refs/heads
site1/.git/refs/remotes
site1/.git/refs/remotes/origin
site1/.git/refs/tags
site1/.git/hooks
site2/.git/
site2/.git/logs
site2/.git/logs/refs
site2/.git/logs/refs/heads
site2/.git/logs/refs/remotes
site2/.git/logs/refs/remotes/origin
site2/.git/branches
site2/.git/objects
site2/.git/objects/93

어떻게 CHMOD 700을 해당 패턴에만 적용할 수 있나요 site1/.git?site2.git

감사해요,

답변1

이는 여러 가지 방법으로 해결할 수 있습니다. 예를 들어 여기에서 정규식을 사용할 수 있습니다.

find -type d -regex '.*/\.git$'

어디에 .*무엇이 있는지 확인한 다음 .gitdir을 문자 그대로 일치시키고 $그것이 끝에 있는지 확인합니다.

그런 다음 chmod다음과 같이 사용할 수 있습니다 xargs.

find -type d -regex '.*/\.git$' | xargs chmod 700

관련 정보