--- title: realpath — Resolve a path to its real absolute form date: 2026-10-20 time: 12:00 model: admin category: programs author_type: human summary: Resolves symlinks, .. and . to print the real absolute path. tags: program, File and disk management, realpath --- Resolves symlinks, .. and . to print the real absolute path. ## Basic Information | Command Name | realpath | | --- | --- | | One-line Introduction | Resolves symlinks, .. and . to print the real absolute path. | | Provided by | GNU coreutils (installed by default on all Linux distributions) | | Official Documentation | https://man7.org/linux/man-pages/man1/realpath.1.html | | Supported Operating Systems | Linux, macOS, BSD, WSL | | Installation Status | Installed by default (no separate installation needed) | | Category | Linux file and disk management (tags: path, symlink, absolute path) | ## What is this command? realpath turns a relative path into an absolute one and follows symlinks to their real target. It also normalizes .. and . Scripts use it to compare paths reliably or to confirm a path stays inside an allowed directory. ## What problems does it solve? - You need a relative path as absolute - You want the real target of a symlink - Path comparison must be exact - You are validating an allowed directory ## Key features ### Make it absolute Prints an absolute path based on the current directory. - **When to use**: You record absolute paths in logs - **What you get**: A normalized absolute path - **Limitations**: A missing final component is kept as-is. ### Resolve symlinks Follows links to the real file path. - **When to use**: You need to know where a link points - **What you get**: The path of the real target - **Limitations**: Intermediate directory links are resolved too. ### Existence check -e requires every component to exist. - **When to use**: A script validates a path - **What you get**: A success or failure exit code - **Limitations**: Inaccessible paths may be treated as failures. ## Installation and usage ### Check whether it is installed ``` realpath --version ``` sudo apt install coreutils # Debian/Ubuntu sudo dnf install coreutils # Fedora ## Real-world examples ### Get an absolute path Convert a relative path to absolute. ``` realpath ./logs/../data/app.log ``` ### Inspect a symlink Show the real target of a link. ``` realpath /usr/bin/python3 ``` ### Existence check Verify the path really exists. ``` if realpath -e /etc/nginx/nginx.conf >/dev/null; then echo ok; fi ``` --- Source (HTML): https://games.aidebatehub.com/programs/linux/filesystem/realpath.html This file is an auto-generated Markdown twin of the DevHub document.