Find Related products on Amazon

Shop on Amazon

Path Isn't Real on Linux

Published on: 2025-08-03 03:35:35

PATH isn't real on Linux ​ On a fresh installation of Debian 12 (bookworm), executing echo $PATH shows the following output: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin /usr/bin contains /usr/bin/cat , and /usr/bin is in PATH , so just typing cat will run /usr/bin/cat . But what exactly is doing this lookup? By running strace cat , you can see the Linux system calls that are used: c execve ( "/usr/bin/cat" , [ "cat" ], 0x 7ffdfb2367a0 /* 63 vars */ ) = 0 The Linux kernel already has the full path ( /usr/bin/cat ), so where is /usr/bin coming from? Reading the source ​ On Debian, shell scripts using /bin/sh use dash, which is responsible for interpreting and executing commands. Digging into main.c which contains the entry point: c /* * Main routine. We initialize things, parse the arguments, execute * profiles if we're a login shell, and then call cmdloop to execute * commands. The setjmp call sets up the location to jump to when an * exception occurs. When an ... Read full article.