Linux and shell basics
To work with an embedded Linux board, the file system, permissions, processes and shell scripts have to be second nature. A summary of the commands used most.
File system
| Path | Contents |
|---|---|
| /bin, /usr/bin | Executables |
| /etc | Configuration files |
| /dev | Device files (ttyS0, i2c-1, spidev0.0) |
| /sys | Kernel objects (GPIO, LEDs, driver attributes) |
| /proc | Processes, system information |
| /var/log | Logs |
In Linux devices are files too. For a serial port you open /dev/ttyS0 and read and write it.
Commands used most
ls -l, cd, cp, mv, rm, cat, less # files
grep, find # searching
ps, top, kill # processes
dmesg # kernel messages (driver logs)
chmod, chown # permissions
ip addr, ping, ssh, scp # network
RoadmapSee where this note sits in Embedded Linux→Permissions
-rwxr-x--- is the read, write and execute permission for owner / group / others. If an ordinary user cannot open /dev/i2c-1, add the user to the group or use a udev rule.
Shell scripts
They automate post-boot set-up, log collection and repeated tests.
#!/bin/sh
for i in $(seq 1 100); do
cat /sys/class/thermal/thermal_zone0/temp >> temp.log
sleep 1
done
What is unfamiliar to an MCU developer is that "several programs run at once and the operating system manages the resources". Hardware is touched only through kernel drivers.