File Operations

realpath

Resolve the absolute canonical path by expanding all symlinks and relative references.

Synopsis

syntax
realpath [OPTION]... FILE...

Examples

Get absolute path of a relative reference
realpath ./script.sh
Resolve all symlinks, error if not found
realpath -e /usr/local/bin/node
Print path relative to /home
realpath --relative-to=/home /etc/hosts

Common options

FlagDescription
-eAll components must exist
-mNo component need exist
-sDo not resolve symlinks
--relative-toPrint path relative to given directory

About realpath

The `realpath` command resolve the absolute canonical path by expanding all symlinks and relative references. File operation commands are essential for navigating and managing the Linux filesystem.

They form the backbone of everyday system administration and development workflows. Mastering these commands enables you to efficiently create, move, copy, and organize files and directories from the terminal, which is often faster and more scriptable than graphical alternatives.

The command accepts 4 commonly used flags shown above, though the full set of options is available in the man page (`man realpath`). The 3 examples on this page cover typical real-world usage patterns that you can copy and adapt for your own workflows.

Related commands

More File Operations Commands

Other commands in the File Operations category

Related tools