I have been having an overheating issue which makes my laptop shutdown immediately. Is there anyway to monitor the temperature from the sensor and scale down the CPU frequency to avoid that problem? Is there any existing software or shell script that can handle that job?
You should have a look at
cpufreq-info. On Debian and derived distros they are in the
cpufrequtils package. For example, on an old laptop with a bad fan that I use as a file server at home I have made these settings:
sudo cpufreq-set -c 0 -g ondemand -u 800000 sudo cpufreq-set -c 1 -g ondemand -u 800000
There are such tools, but you should look into blowing dust out of your laptop cooler heatsink instead. If that doesn't help you might want to examine/replace thermal grease under heatsink or ultimately bring your laptop to authorized service.
Note: disassembling a typical laptop might be not a trivial task, but instructions can be found on the web rather easily. Consult your warranty card before disassembling!