Useful one liners for linux

Some one liners that can be handy in our systems.

Get the GPIO names and numbers (exynos)

 for file in /sys/class/gpio*; do echo -n "$file - ";cat $file/label; done

Get PMIC regulator names, values, and status

For Kernel 3.8:

 for file in /sys/devices/platform/s3c2440-i2c.0/i2c-0/0-0009/max77686-pmic/regulator*; do echo -n "$file - ";cat $file/name; cat $file/microvolts; cat $file/state; done

For Kernel 4.8:

 for file in /sys/class/i2c-dev/i2c-0/device/0-0009/regulator*; do echo -n "$file - ";cat $file/name ; cat $file/microvolts; cat $file/state; done

Control exynos CPUs behavior

Shut down cores:

 for file in /sys/devices/system/cpu* ; do echo 0 > $file/online; done

Turn on cores:

 for file in /sys/devices/system/cpu* ; do echo 1 > $file/online; done

Powersave mode:

 echo "powersave" > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor

Performance mode:

 echo "performance" > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor

Stress cores: do it at your own risk

Activate:

 for i in 1 2 3 4; do while : ; do : ; done & done

Deactivate

 for i in 1 2 3 4; do kill %$i; done