Skip to Content
Navigation:

A stick figure smiling

Here's a preview from my zine, Bite Size Linux! If you want to see more comics like this, sign up for my saturday comics newsletter or browse more comics!

Image of a comic. To read the full HTML alt text, click "read the transcript". get the zine!
read the transcript!

The Linux kernel has code to do a lot of things

  • read from a hard drive
  • make network connections
  • create new processes
  • kill process
  • change file permissions
  • keyboard drivers

Your program doesn’t know how to do those things

program, blithely: TCP? dude I have no idea how that works.

program: NO, I do not know how the ext4 filesystem is implemented. I just want to read some files!

Programs ask Linux to do work using system calls

program: please write to this file (switch to running kernel code)

Linux: done! I wrote 1097 bytes! (program resumes)

Every program uses system calls

Python program: I use the ‘open’ syscall to open files Java program: me too! C program: me three!

And every system call has a number (e.g. chmod is 390 on x86.64)

so what’s actually going on when you change a file’s permissions is:

program: run syscall #90 with these arguments Linux: ok!

You can see which system calls a program is using with strace

$ strace ls /tmp

will show you evey system call ’ls’ uses! it’s really fun!

warning: strace has high overhead so don’t run it on your production database