3

If I understand correctly, in Linux, everything is a path, right down to each piece of hardware. I am trying to get information about how my sensors are structured, so I thought I would just use tree to map out all the things in my hwmon directory. However, tree does not behave the same with this directory as I am accustomed to.

When I run tree on a normal directory, I get the subdirectory structure without using the -R or -L flags:

$ tree /home
/home
└── boss
    ├── clones
    ├── Desktop
    ├── Documents
    │   ├── modules.txt
    │   ├── old_docs
    │   │   └── assorted
    │   └── prepscript.txt
    ├── Downloads
    ├── Music
    ├── Pictures
    ├── Public
    ├── Templates
    └── Videos

12 directories, 2 files

but I try to do the same with HWmon, it only goes one level deep, even if I do use the -R flag and even though there is stuff deeper:

$ tree /sys/class/hwmon/
/sys/class/hwmon/
├── hwmon0 -> ../../devices/pci0000:40/0000:40:01.3/0000:43:00.0/hwmon/hwmon0
├── hwmon1 -> ../../devices/pci0000:00/0000:00:01.3/0000:09:00.0/hwmon/hwmon1
├── hwmon2 -> ../../devices/pci0000:40/0000:40:03.1/0000:44:00.0/hwmon/hwmon2
├── hwmon3 -> ../../devices/pci0000:00/0000:00:18.3/hwmon/hwmon3
├── hwmon4 -> ../../devices/pci0000:00/0000:00:19.3/hwmon/hwmon4
├── hwmon5 -> ../../devices/virtual/thermal/thermal_zone0/hwmon5
└── hwmon6 -> ../../devices/platform/nct6775.656/hwmon/hwmon6

7 directories, 0 files
$ tree /sys/class/hwmon/hwmon0
/sys/class/hwmon/hwmon0
├── device -> ../../../0000:43:00.0
├── fan1_input
├── name
├── power
│   ├── async
│   ├── autosuspend_delay_ms
│   ├── control
│   ├── runtime_active_kids
│   ├── runtime_active_time
│   ├── runtime_enabled
│   ├── runtime_status
│   ├── runtime_suspended_time
│   └── runtime_usage
├── pwm1
├── pwm1_enable
├── pwm1_max
├── pwm1_min
├── subsystem -> ../../../../../../class/hwmon
├── temp1_auto_point1_pwm
├── temp1_auto_point1_temp
├── temp1_auto_point1_temp_hyst
├── temp1_crit
├── temp1_crit_hyst
├── temp1_emergency
├── temp1_emergency_hyst
├── temp1_input
├── temp1_max
├── temp1_max_hyst
├── uevent
└── update_interval

3 directories, 27 files

What causes this difference in behavior, and can I just get a simple tree of all the devices?

1 Answer 1

7

tree behaves that way because it doesn’t dereference symlinks by default. The -l option will change that:

tree -l /sys/class/hwmon/

but you’ll have fun making sense of all the output.

5
  • Wow, that is indeed some confusing output. Is there a way to get the structure as it would appear if I browsed through it?
    – Stonecraft
    Dec 2, 2018 at 20:22
  • 2
    @Thoughtcraft the problem is mostly because the device link goes up the tree (to the parent device), therefore this command shows the entire device tree, not just a few subtrees. I guess you can do e.g. tree -d /sys/class/hwmon/*/ to show the directory structure and symlinks to directories, and chase the device links yourself.
    – sourcejedi
    Dec 2, 2018 at 21:06
  • Awesome, if I want to go deeper I can keep adding stars like: tree -d -R /sys/class/hwmon/*/*/ */*
    – Stonecraft
    Dec 2, 2018 at 21:14
  • Might want to check for infinite loops.
    – Joshua
    Dec 3, 2018 at 0:48
  • 1
    @Joshua tree -l does that on its own. Dec 3, 2018 at 5:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .