$ man 2 intro
Syscall reference
One card per kernel interface Rod has actually written up: when it landed, whether glibc bothered to wrap it, the flags worth knowing, the errno you'll hit at 2 a.m., and what the BSDs did instead (usually first, usually smaller). Every version number is lifted from the man page cited on the card. If you want the war story, each card links to the full Tip.
Not sure what the box in front of you has? Paste its uname -sr into the kernel check and it'll tell you which of these you can call and what you're missing. Browse the flags and arguments index or the errno reference if you already know the name. Scripts can pull the whole table from /syscalls.json.
58 of 58
| Other side of the fence | |||
|---|---|---|---|
| cachestat(2)Query page cache status (resident, dirty, writeback, evicted) for a byte range of an open file. | 6.5 | Filesystem | FreeBSD: no equivalent. mincore(3) is available with the same mmap-first requirement as Linux mincore(2). |
| capset(2)Raw syscall to set a thread's permitted, effective and inheritable capability sets. | 2.2 | Security | FreeBSD: no POSIX.1e-style process capability sets; Capsicum (cap_enter(2), cap_rights_limit(2)) restricts per-fd rights instead. OpenBSD: none; pledge(2). |
| clone3(2)Fork a child process using a struct-based API; write a pidfd atomically with CLONE_PIDFD. | 5.3 | Processes | FreeBSD: pdfork(2) (FreeBSD 9.0) writes a process descriptor on fork in a single call; pdkill(2), pdwait4(2), and EVFILT_PROCDESC in kqueue(2) complete the API. OpenBSD: none. |
| close_range(2)Close, or mark close-on-exec, every file descriptor in a range in one call. | 5.9 | File descriptors | FreeBSD: close_range(2) with CLOSE_RANGE_CLOEXEC (FreeBSD 12.2) and closefrom(2) (FreeBSD 8.0). OpenBSD: closefrom(2) (OpenBSD 3.5). |
| copy_file_range(2)Copy a range of bytes between two file descriptors entirely inside the kernel, with server-side offload on NFS 4.2 and reflink on btrfs. | 4.5 | I/O | FreeBSD: copy_file_range(2) (FreeBSD 13.0), identical interface; uses ZFS reflink when both fds are on the same dataset. |
| eventfd(2)Create a kernel-backed 64-bit counter fd for wakeups between threads or processes. | 2.6.22 | Events | FreeBSD: eventfd(2) (FreeBSD 13.0). OpenBSD: closest is EVFILT_USER in kqueue(2). |
| execveat(2)Execute a program via file descriptor instead of path, eliminating the TOCTOU race between verify and exec. | 3.19 | Processes | FreeBSD has fexecve(3), which achieves the same result via /dev/fd/N rather than a native syscall. OpenBSD does not expose fexecve. |
| fallocate(2)Allocate disk space, punch holes, collapse or insert byte ranges in a file. | 2.6.23 | Filesystem | No direct equivalent. posix_fallocate(3) on FreeBSD writes zeros if the filesystem does not support native preallocation. |
| fanotify_init(2)Create an fanotify group: VFS-level file access events with live fds and blockable opens. | 2.6.37 | Events | FreeBSD and OpenBSD: no equivalent. kqueue(2) EVFILT_VNODE gives after-the-fact vnode notifications only, with no permission decisions. |
| flock(2)Apply or remove an advisory whole-file lock tied to an open file description. | 4.2BSD; Linux 2.0 | File descriptors | FreeBSD: flock(2) (appeared in 4.2BSD). OpenBSD: flock(2) (first appeared in 4.1cBSD per its man page). On the modern BSDs flock and fcntl locks interact; on Linux they don't (except over NFS/SMB). |
| fsopen(2)Open a filesystem context: step one of the fd-based mount API (fsconfig, fsmount, move_mount). | 5.2 | Filesystem | FreeBSD: nmount(2) takes structured name/value option iovecs (FreeBSD 5.0), but it's still a one-shot call. OpenBSD: none; plain mount(2). |
| futex(2)Fast userspace locking: wait on or wake threads sleeping on a 32-bit word in memory. | 2.6.0 | IPC | FreeBSD: _umtx_op(2) (UMTX_OP_WAIT_UINT / UMTX_OP_WAKE), the undocumented-in-spirit substrate under libthr. OpenBSD: futex(2), added in OpenBSD 6.2. |
| getrandom(2)Fill a buffer with random bytes from the kernel CSPRNG, without opening /dev/urandom. | 3.17 | Security | FreeBSD: getrandom(2) since FreeBSD 12.0, plus arc4random(3). OpenBSD: getentropy(2) since OpenBSD 5.6; arc4random(3) for bulk use. |
| inotify_add_watch(2)Watch a file or directory for filesystem events and read them off a file descriptor. | 2.6.13 | Events | FreeBSD uses kqueue(2) + kevent(2) with EVFILT_VNODE. Watches are per-fd: open the file or directory, then register with kevent. NOTE_WRITE, NOTE_RENAME, NOTE_DELETE, and NOTE_ATTRIB are the main filter flags. Overflow is explicit and per-event rather than a single queue-full signal. More granular, fewer surprises. |
| io_uring_setup(2)Create an io_uring instance: shared submission/completion rings for async I/O. | 5.1 | I/O | FreeBSD: aio(4) (kernel option since FreeBSD 3.0, in all kernels since FreeBSD 11.0), with completions deliverable through kqueue(2) EVFILT_AIO. OpenBSD: none. |
| ioprio_set(2)Set a thread's I/O scheduling class and priority (ionice is the CLI wrapper). | 2.6.13 | I/O | FreeBSD and OpenBSD: no per-process I/O priority syscall. |
| jail(2)Create a FreeBSD jail and lock the current process into it (jail_set/jail_attach for more). | FreeBSD 4.0 | Sandboxing | FreeBSD · Linux: no single equivalent; namespaces via clone(2)/unshare(2)/setns(2) plus chroot/pivot_root, assembled by container runtimes. |
| kcmp(2)Compare whether two resources in different processes refer to the same kernel object. | 3.5 | Processes | No equivalent. FreeBSD and OpenBSD have no kcmp. Closest approach is parsing /proc/<pid>/fd symlinks, which is racy. |
| keyctl(2)Manipulate the kernel key retention service: read, revoke, time out and link keys and keyrings. | 2.6.10 | Security | FreeBSD and OpenBSD: no kernel keyring equivalent. |
| landlock_create_ruleset(2)Create a Landlock ruleset fd, step one of unprivileged filesystem/network sandboxing. | 5.13 | Sandboxing | OpenBSD: unveil(2) (OpenBSD 6.4). FreeBSD: Capsicum capability mode via cap_enter(2). |
| madvise(2)Advise the kernel how a memory range will be used: free it, page it out, exclude it from dumps. | 4.4BSD | Memory | FreeBSD: madvise(2) (4.4BSD) with MADV_FREE and MADV_NOCORE; minherit(2) INHERIT_ZERO for wipe-on-fork. OpenBSD: madvise(2) (since OpenBSD 2.7). |
| membarrier(2)Issue a memory barrier across all threads in the calling process, offloading the barrier cost from readers to the writer. | 4.3 | Memory | No equivalent on FreeBSD. liburcu falls back to sending a signal to each reader thread, whose signal handler executes the barrier. Correct but slower than kernel-assisted IPIs. |
| memfd_create(2)Create an anonymous RAM-backed file with no path, optionally sealable. | 3.17 | Memory | FreeBSD: memfd_create(2) (FreeBSD 13.0), an SHM_ANON shared memory object that supports MFD_ALLOW_SEALING. OpenBSD: none. |
| memfd_secret(2)Create memory removed from the kernel's direct map, mapped only by fd holders. | 5.14 | Memory | none |
| mlock(2)Lock pages into RAM so they can't be swapped out; mlockall() does the whole address space. | POSIX.1-1996 (SVr4) | Memory | FreeBSD: mlock(2)/mlockall(2) (mlock since 4.4BSD); madvise(2) MADV_NOCORE for core-dump exclusion. OpenBSD: mlock(2)/mlockall(2) (4.4BSD). |
| mount_setattr(2)Change VFS-layer mount attributes on an existing mount or subtree, optionally recursing. | 5.12 | Filesystem | FreeBSD: mount(2) with MNT_UPDATE reconfigures an existing mount, and it works correctly on the named mount record. Per-jail mount restrictions go through jail_set(2) parameters (allow.noexec, etc.) rather than per-mount attribute walks. There is no AT_RECURSIVE equivalent; recursive flag changes are manual. |
| mseal(2)Permanently seal a virtual memory area against mprotect, munmap, and MAP_FIXED remapping. | 6.10 | Memory | OpenBSD: mimmutable(2) since 7.3 (April 2023) provides equivalent sealing against mprotect and munmap. FreeBSD: no equivalent in base as of 14.2. |
| name_to_handle_at / open_by_handle_at(2)Get a stable opaque file handle for a path and reopen it later, surviving remounts and bind-mount rearrangement. | 2.6.39 | Filesystem | No equivalent. FreeBSD has fhopen(2) for NFS file handles (superuser only). macOS has nothing. |
| openat2(2)Open a file with kernel-enforced path-resolution constraints (RESOLVE_* flags). | 5.6 | Filesystem | FreeBSD: O_RESOLVE_BENEATH flag to openat(2) (FreeBSD 13), which fails with ENOTCAPABLE on escape. OpenBSD: none; closest is unveil(2). |
| perf_event_open(2)Open a file descriptor for a hardware or software performance counter. | 2.6.31 | Tracing | FreeBSD: hwpmc(4) and pmc(3)/pmcstat(8). Allocate via pmc_allocate(3), attach to a process, read via pmc_read(3). No group-atomic read. pmcstat -S instructions -p $pid is the closest equivalent. |
| pidfd_getfd(2)Duplicate a file descriptor out of another process, addressed by its pidfd. | 5.6 | File descriptors | none; on FreeBSD and OpenBSD the closest is passing the descriptor with SCM_RIGHTS over a unix(4) socket, which needs the owner's cooperation. |
| pidfd_open(2)Get a file descriptor that refers to a process, immune to PID reuse. | 5.3 | Processes | FreeBSD: process descriptors created at fork time with pdfork(2), plus pdgetpid(2) and EVFILT_PROCDESC in kqueue(2) (FreeBSD 9.0). OpenBSD: none. |
| pidfd_send_signal(2)Send a signal to the process a pidfd refers to, without PID-reuse races. | 5.1 | Processes | FreeBSD: pdkill(2) on a process descriptor from pdfork(2) (FreeBSD 9.0). OpenBSD: none. |
| pkey_alloc / pkey_mprotect(2)Allocate a memory protection key and use it to gate access to a memory region via a per-thread register, without a syscall per permission switch. | 4.8 | Memory | FreeBSD: no equivalent in base as of 14.2. ARM: MTE (Memory Tagging Extension, ARMv8.5-A) provides a related but incompatible mechanism. OpenBSD: none. |
| pledge(2)Restrict the process to named groups of system operations; violations kill it with SIGABRT. | OpenBSD 5.9 | Sandboxing | OpenBSD · Linux: no single equivalent; combine seccomp(2) filters, Landlock (landlock_create_ruleset(2)) and prctl(PR_SET_NO_NEW_PRIVS). FreeBSD: Capsicum, cap_enter(2) and cap_rights_limit(2). |
| posix_fadvise(2)Declare the expected access pattern for a file region so the kernel can tune readahead and page-cache reclaim. | 2.5.60 | I/O | FreeBSD: posix_fadvise(2) since FreeBSD 9.0; POSIX_FADV_NOREUSE is implemented as a sequential-access hint. OpenBSD does not implement posix_fadvise; use madvise(2) on mmap-ed regions instead. |
| prctl(2)Per-process/thread control knobs: no_new_privs, dumpable, parent-death signal, VMA names and more. | 2.1.57 | Processes | FreeBSD: procctl(2) (FreeBSD 9.3), including PROC_PDEATHSIG_CTL (FreeBSD 11.2, modeled on PR_SET_PDEATHSIG) and PROC_NO_NEW_PRIVS_CTL. OpenBSD: none; pledge(2) covers the sandboxing side. |
| preadv2 / pwritev2(2)Scatter/gather I/O at an offset with per-call flags: RWF_NOWAIT, RWF_HIPRI, RWF_DSYNC, RWF_SYNC, RWF_APPEND. | 4.6 | Filesystem | FreeBSD has preadv/pwritev (FreeBSD 6, 2005) but no preadv2/pwritev2 and no RWF_* flags. Per-call durability requires explicit fdatasync(2)/fsync(2). Polled I/O is handled at the GEOM/cam_iosched layer, not via fd flags. |
| process_madvise(2)madvise() for another process's address space, addressed by pidfd and an iovec of ranges. | 5.10 | Memory | FreeBSD and OpenBSD: none; madvise(2) only works on the caller's own address space. |
| process_vm_readv(2)Read from or write to another process's virtual address space in one syscall, without attaching via ptrace. | 3.2 | Memory | FreeBSD/OpenBSD: no direct equivalent. Use ptrace(2) with PT_IO for bulk cross-process memory transfers; semantically similar but requires an attach. |
| renameat2(2)Rename or atomically swap two filesystem entries, with optional no-overwrite and exchange flags. | 3.15 | Filesystem | No equivalent in FreeBSD or OpenBSD. Both support atomic rename(2) for same-directory replace, but neither has an EXCHANGE primitive at the VFS layer. |
| rseq(2)Register a per-thread struct that the kernel keeps updated with the current CPU ID, enabling lock-free per-CPU data updates via restartable critical sections. | 4.18 | Scheduling | No equivalent on FreeBSD, OpenBSD, or NetBSD. Per-CPU userspace data structures at this layer are Linux-specific. Portable alternative: sched_getcpu(3) on Linux, thread-local storage everywhere else. |
| sched_setaffinity(2)Set the set of CPUs a thread may run on (taskset is the CLI wrapper). | 2.5.8 | Processes | FreeBSD: cpuset_setaffinity(2) (FreeBSD 7.1) and the cpuset(1) tool. OpenBSD: none. |
| sched_setattr(2)Set scheduling policy and attributes for a thread, including SCHED_DEADLINE runtime/deadline/period reservations. | 3.14 | Scheduling | No SCHED_DEADLINE. FreeBSD has rtprio(2) and POSIX SCHED_FIFO/SCHED_RR via sched_setscheduler(2); there is no admission-controlled reservation scheduler. |
| SCM_RIGHTSPass open file descriptors to another process over a UNIX domain socket. | unknown | IPC | FreeBSD and OpenBSD: the same SCM_RIGHTS control message on unix(4) sockets. |
| seccomp(2)Set the thread's seccomp state: strict mode or a BPF filter on every syscall. | 3.17 | Sandboxing | OpenBSD: pledge(2) (OpenBSD 5.9), coarse promise strings rather than BPF. FreeBSD: Capsicum capability mode via cap_enter(2). |
| setns(2)Move the calling thread into an existing namespace, given an fd for it (or a pidfd). | 3.0 | Processes | FreeBSD: no namespaces; jail_attach(2) (FreeBSD 5.1) is the closest thing to joining an existing isolated environment. OpenBSD: none. |
| signalfd(2)Accept signals by reading a file descriptor instead of running a handler. | 2.6.22 | Events | FreeBSD and OpenBSD: EVFILT_SIGNAL in kqueue(2). |
| SO_REUSEPORTLet multiple sockets bind one address:port; the kernel spreads traffic across them. | 3.9 | I/O | FreeBSD: SO_REUSEPORT_LB load-balances TCP and UDP across up to 256 sockets per group. OpenBSD: SO_REUSEPORT allows duplicate bindings, documented for multicast/broadcast reception rather than load balancing. |
| splice(2)Move data between a pipe and another fd without copying through userspace. | 2.6.17 | I/O | FreeBSD: sendfile(2) for file-to-socket (FreeBSD 3.0), and the SO_SPLICE socket option for socket-to-socket (FreeBSD 14.3). OpenBSD: SO_SPLICE via setsockopt(2) (OpenBSD 4.9). |
| statx(2)Extended stat: request specific fields, get birth time, inode attribute flags and mount ID. | 4.11 | Filesystem | FreeBSD: no statx; stat(2) already carries st_birthtim (st_birthtime). OpenBSD: no statx; plain stat(2)/fstatat(2). |
| sync_file_range(2)Submits async writeback for a byte range and optionally waits for it, without syncing inode metadata. Lets sequential writers overlap I/O with compute while deferring the durability-barrier fdatasync to checkpoint time. | 2.6.17 | I/O | No direct BSD equivalent. FreeBSD and OpenBSD rely on msync(2) (MAP_ASYNC) or fdatasync(2) for range writeback. ZFS on FreeBSD makes msync less relevant for most use cases. |
| tee(2)Duplicate data from one pipe into another without consuming it from the source. | 2.6.17 | I/O | none |
| timerfd_create(2)Create a timer that reports expirations through a readable file descriptor. | 2.6.25 | Events | FreeBSD: native timerfd(2) (FreeBSD 14.0), or EVFILT_TIMER in kqueue(2). OpenBSD: EVFILT_TIMER in kqueue(2). |
| unshare(2)Create new namespaces and move the calling process into them without forking. | 2.6.16 | Processes | FreeBSD: jail(2) (FreeBSD 4.0) wraps filesystem, network, and PID visibility in one coarser-grained call. OpenBSD: none; isolation is pledge(2), unveil(2), and chroot(2). |
| unveil(2)Hide the whole filesystem except the paths you name, with per-path r/w/x/c permissions. | OpenBSD 6.4 | Sandboxing | OpenBSD · Linux: Landlock (landlock_create_ruleset(2)) is the closest path-based restriction, though denied paths aren't made invisible. FreeBSD: Capsicum cap_enter(2) with pre-opened directory fds. |
| userfaultfd(2)Create an fd that lets userspace resolve page faults on registered memory ranges. | 4.3 | Memory | none |
| vmsplice(2)Splice user-space pages directly into a pipe; with SPLICE_F_GIFT the kernel takes ownership of those pages without copying. | 2.6.17 | IPC | No equivalent. FreeBSD covers the user-memory-to-socket path with sendfile(2) (FreeBSD 3.1). For user-memory-to-pipe there is only write()/writev(); the splice family is Linux-specific. |
"Since" is the Linux kernel release unless the row says otherwise. For the full arguments behind each card, see Rod's Tips From the Console.