namei
Follow pathname, showing each path component
TLDR
Resolve the pathnames specified as the argument parameters
Display the results in a long-listing format
Show the mode bits of each file type in the style of ls
Show owner and group name of each file
Don't follow symlinks while resolving
SYNOPSIS
namei [OPTIONS] PATHNAME...
PARAMETERS
-l, --long
Uses a long listing format, similar to ls -l, showing more details like device, inode, permissions, link count, UID, GID, size, and last modification time.
-m, --mounts
Displays mount point information for directories that are mount points.
-n, --no-stop
Prevents namei from stopping at the first non-existent file or directory component. It continues processing the rest of the path, if possible.
-o, --offset=NUMBER
Starts resolving the path from the NUMBERth character of the given pathname.
-p, --parent
Prints each parent directory as it is encountered during the path traversal, showing the full hierarchy.
--help
Displays a help message and exits.
--version
Prints version information and exits.
DESCRIPTION
The namei command is a utility used to traverse a given pathname, resolving symbolic links and reporting the type of each component encountered along the way. It's particularly useful for understanding how the kernel resolves a file path, especially when dealing with nested directories, symbolic links, or mount points.
For each component of the path, namei prints an indicator (e.g., 'f:' for regular file, 'd:' for directory, 'l:' for symbolic link), followed by the component's name. If a symbolic link is encountered, it also shows where the link points. This detailed output helps in debugging 'file not found' errors, understanding complex file system structures, or verifying the true target of symbolic links. Unlike commands like ls or stat that focus on the final target, namei provides a step-by-step breakdown of the entire path resolution process. It's a powerful diagnostic tool for system administrators and developers.
CAVEATS
namei only reports on the path resolution process and does not modify the file system.
Its output can become very verbose for deeply nested paths or long chains of symbolic links.
By default, it stops processing a path as soon as a non-existent component is found, unless -n is used.
OUTPUT INTERPRETATION
The output of namei uses specific prefixes to denote the type of each path component:
f: - regular file
d: - directory
l: - symbolic link (followed by '->' and the link target)
b: - block device
c: - character device
s: - socket
p: - named pipe (FIFO)
?: - non-existent component or error
(mount point) - indicates a directory is a mount point (when using -m)
HISTORY
The namei command is a long-standing utility within the util-linux project, a collection of essential userspace utilities for Linux. Its primary purpose has always been to provide a detailed, step-by-step trace of how the kernel resolves a file path, making it an invaluable diagnostic tool since early Linux distributions. It has maintained its core functionality over time, focusing on path resolution and symbolic link following, making it a reliable component for system debugging and understanding file system intricacies.