Korean

realpath — Resolve a path to its real absolute form

Linux / File and disk management / realpath.html

File and disk managementOriginalRegistered 2026-10-20T09:00:00+09:00

Resolves symlinks, .. and . to print the real absolute path.

Basic Information

Command Namerealpath
One-line IntroductionResolves symlinks, .. and . to print the real absolute path.
Provided byGNU coreutils (installed by default on all Linux distributions)
Official Documentationhttps://man7.org/linux/man-pages/man1/realpath.1.html
Supported Operating SystemsLinux, macOS, BSD, WSL
Installation StatusInstalled by default (no separate installation needed)
CategoryLinux 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