Tutorial: Dow Hurst Linux Debugging Hints
Editors Note: Dow4Hurst has been very active on the SwitchDoc Labs Forum (forum.switchdoc.com) in helping folks debug their Raspberry Pi Linux Debugging problems. He is great at it! I’ve collected a couple of his postings with his permission and have re-printed them here. Good stuff!
Where to Learn about Your Raspberry Pi Linux System
Herve,
You are doing fine for a linux beginner. I’d recommend using this webpage as a starting point for learning Debian linux which is the linux variant that Raspbian linux is built from. Raspbian is what is running on the pi that comes on the SD card from SwitchDoc Labs.
www.tecmint.com/free-online-linux-learning-guide-for-beginners/
I’d skip Chapter 1 for now. You just need to learn an editor like vim or nano and get used to it. Plus you need to learn some linux commands.
Chapters 2-5 are essential to try out the different commands.
Chapter 6, you only need the APT link.
Chapter 7, the first three links are useful.
Chapter 8, just read about the tar command, which is the first link, and then rsync, which is the fifth link. The rest you can look at later if needed.
Chapter 9, read links one and two about linux filesystems. I consider this essential reading.
Skip chapters 10 and 11 for now.
Chapter 12 is essential.
Skip Chapters 13-16 for now. You can worry about security, webservers, and databases later!
Chapter 17 is really good for getting some basics on shell scripting. I’d cover the first two links and maybe the third. Access the rest later.
Skip Chapters 18-21 unless you want to read test questions.
My secret to getting linux troubleshooting done is to use google to remind myself how to use a command. But, the tutorial above is needed so you know what command you might want to try using.
Also, a old wise sysadmin told me long ago that the “man” command was my friend and that “man -k” was super useful. He is correct. Anytime you can’t remember the name of a command you want to use, you can try to find it quickly with the “man -k” command. For example, I can’t remember how what the name of the command to show what programs or processes are running on the pi. The word program is too general, but the word process might find what we want:
man -k process
gives a long list of results but contains:
ps (1) - report a snapshot of the current processes.
top (1) - display Linux processes
which after reading the long list stand out as good possible commands to try. Using the “man” command to display the manual pages for each of these commands teaches us how we might use them.
Below are links to tutorials on nano and vim:
Guide to using the Nano editor.
Best tutorial for the VIM editor.
Of course, you can always ask here and I’m sure you will get answers on how to quickly resolve problems with linux commands.
Dow Hurst
Taking Care of Your Raspberry Pi SD Card
Ms. A, I was reading through the thread. You originally had the SkyWeather2 updating weatherstem. Then, it quit and now it seems you can’t write data to the SD card. If the file system has been remounted as read only, due to a filesystem error, then that would prevent any writes. Turning the raspberry pi off without going through a shutdown procedure can cause file system corruption. I would think you wouldn’t be able to reboot the device normally if you turned it off and back on again, so don’t do that yet. It is weird you don’t seem to able to update the JSON file and this is one possible reason.
If you haven’t rebooted the pi in a while, try this code to check for read only filesystems. We would be looking for /dev/root to be mounted as read only if this is what has happened.
awk '$4~/(^|,)ro($|,)/' /proc/mounts
That should only show
tmpfs /sys/fs/cgroup tmpfs ro,nosuid,nodev,noexec,mode=755 0 0
but if /dev/root is read only, where the /home/pi directory is located, then you would see it show up in the list. It’s a hail mary, but worth checking.
Don’t reboot the pi, but to shutdown and restart the pi you would normally use this command:
sudo shutdown -r now
but if you have a pi where the SkyWeather2 python script has crashed, but you can still access via ssh and run commands, then rebooting with this seems to work well. This preserves the filesystem too by forcing the disk to sync.
echo s | sudo tee /proc/sysrq-trigger;echo u | sudo tee /proc/sysrq-trigger;echo b | sudo tee /proc/sysrq-trigger
that is all one command, but is multiple magic sysrq commands back to back. It forces a sync, unmounting of the filesystem, and then reboot of the device.
If the root filesystem is read only, then I’d like others to advise what would be the next step. I think you could turn off the pi, and try repairing the filesystem using a different computer that has linux. But, lets see if there is this problem first.