A port of the Plan 9 syscall command to Linux. Rather than going through libc, it calls syscall(2) directly, which makes it useful for testing kernel behaviour, understanding how system calls work, and quick scripting without writing C.
Not every Linux syscall is invocable this way — some require kernel structures that can't be expressed as plain scalars — but the most common ones work fine.
make
make test
make install
make uninstallsyscall [-o -v -l -h] entry [arg ...]
| Flag | Effect |
|---|---|
-o |
Print the contents of buf to stdout after the call |
-n bytes |
With -o, print exactly bytes bytes using fwrite instead of stopping at the first null |
-v |
Print the syscall return value to stderr |
-l |
List all available syscalls and exit |
-h |
Print usage and exit |
| Token | Expands to |
|---|---|
buf |
An 8 KB scratch buffer, passed as a pointer |
stdin |
File descriptor 0 |
stdout |
File descriptor 1 |
stderr |
File descriptor 2 |
Up to 6 arguments can be passed, matching the maximum number of arguments any Linux syscall takes.
Write a string to standard output:
syscall write stdout hello 5Read 5 bytes from stdin and print the buffer:
echo -n hello | syscall -o read stdin buf 5Get the current working directory:
syscall -ov getcwd buf 100Get the PID of the current process:
syscall -v getpidGet 16 bytes of random data from the kernel (1 == GRND_RANDOM):
syscall -ov getrandom buf 16 1Dump all fields of struct utsname across null bytes:
syscall -on 390 uname buf | tr '\0' ' ' | tr -s ' 'Create a directory:
syscall mkdir my-dir 0755Rename a file:
syscall rename old-name new-nameExit with a specific status code:
syscall exit 2List all available syscalls:
syscall -l