Linux in General

This bash script displays the Raspberry Pi's CPU temperature:


#This script outputs the current CPU temperature in degrees Celcius and Farenheit

awk '{printf("%.1fC ",$1/1e3)}' /sys/class/thermal/thermal_zone0/temp awk '{printf("(%.1fF)\n",$1*1.8/1e3)}' /sys/class/thermal/thermal_zone0/temp

Here is how it works:
The awk command, which is used for processing text, retrieves the value stored in


and formats it to one decimal point. Originally, the temperature is stored in Celcius with no decimal point (42774). The awk command's argument of

'{printf("%.1fC ",$1/1e3)}'

does the formatting. Printf comes from the C programming language, it means print with a defined format. Here the format ("%.1fC ") means print all leading digits, a decimal point, and what ever digit is one decimal place past the point, and the character "C" with two spaces immediately after the formatted number. The lower case "f" probably identifies the output as floating point decimal, a data type in the C programming language. The $1 identifies which space delimited field to extract from the text, the "/" is the division operator, and 1e3 means 1 x 10^3, or 1000.

So, 42774 / (1 x 10^3) = 42.774

42.774 formatted to one decimal place (automatically rounding) and adding the "C " = 42.8C or (77.0F).

I've been learning about the startup files .bashrc, .bash_profile and /boot/config.txt

As far as I can tell, /boot/config.txt is roughly equivalent to DOS's config.sys, while .bashrc and .bash_profile are similar in function to DOS's autoexec.bat.

After buying a Raspberry Pi I had the perfect excuse to learn Linux. One of the ways I've been teaching myself is by trying to replicate the commands and results from DOS in Linux. Here is what I have learned so far:


C:\>dir /o:gn /p


pi@raspberrypi ~$ ls --group-directories-first -laFh | more -d


C:\>copy con myfile.txt


pi@raspberrypi ~$ cat > myfile.txt

Take ownership of a directory or file

sudo chown username:group directory

Take ownership of a directory and all subdirectories (recursive)

sudo chown -R username:group directory

Most of the other commands work the same (cd, mkdir, rmdir, etc.).