/sys/class를 보면 모든 내용이 표시되지 않습니다. 이유는 무엇입니까?

/sys/class를 보면 모든 내용이 표시되지 않습니다. 이유는 무엇입니까?

다른 사람들과 마찬가지로 나도 가끔 파일 시스템의 특정 지점에 있는 디렉터리 구조를 나열해야 할 때가 있습니다. 이렇게 했는데 find /path/in/fs/결과는 다음과 같습니다.

/path/in/fs/subfolder1
/path/in/fs/subfolder1/file1
/path/in/fs/subfolder1/subfolder2/yetanothefile
/path/in/fs/subfolder1/subfolder2/yetanothefile2
/path/in/fs/subfolder1/subfolder2/yetanothefile3
/path/in/fs/subfolder1/file2

어떤 면에서 이것은 끝없는 반복 cdls.

/sys/class이제 경로에 디렉터리 구조를 나열하고 싶지만 충분하지 않은 것 같습니다. 다음 두 명령은 이상한 동작을 보여줍니다.

  • (1) 사용 cdls
    root@freak:/sys/class/hwmon# ls
    hwmon0 hwmon1 hwmon2
    root@freak:/sys/class/hwmon# cd hwmon0
    root@freak:/sys/class/hwmon/hwmon0# ls
    이름 전원 하위 시스템 temp1_crit temp1_input uevent
  • find(2) 같은 위치에서 위의 명령을 사용하십시오.
    root@freak:/sys/class/hwmon# 찾기 .
    .
    ./hwmon0
    ./hwmon1
    ./hwmon2

보시다시피, 제 생각에는 이것이 find나에게 모든 것을 보여주지는 않으며 이것이 이상하고 놀라운 행동이라고 생각합니다. 이제 /sys/ 아래에 특별한 것이 있다는 것을 알았습니다. 그러나 모든 것이 여전히 순조롭게 진행되고 있습니다 cd ls. 왜 이런 일이 발생하는지에 대한 답을 가진 사람이 있습니까? 아니면 ./hwmon0 ./hwmon1 ... 등의 항목을 무시하지 않도록 하려면 어떻게 해야 합니까?

답변1

당신이 달릴 때

find .

-P그런 다음 실제로 실행되는 Option으로 기본 설정 됩니다.find -P .

에서 발췌man find

   -P     Never follow symbolic links.  This  is  the  default  behaviour.
      When find examines or prints information a file, and the file is
      a symbolic link, the information used shall be  taken  from  the
      properties of the symbolic link itself.

이것이 find가 아래의 모든 내용을 표시하지 않는 이유입니다 /sys/class/hwmon. 안으로 들어가서 확인하면 모두 심볼릭 링크이므로 확인해야 합니다.find . -follow

자세한 내용은 확인해주세요man find

관련 정보