Back to the command reference

readlink

FilesFundamentals In simulator In real Linux

Print where a symbolic link points

Name: readlink: read a link

You can practise it right away in the simulator, and use it in real Linux mode too.

Description

readlink prints the target stored in a symbolic link. -f resolves every link along the path and prints the final absolute path, a common way to find which file a command really is.

Syntax

readlink [OPTION]... FILE...

Common options

-f / --canonicalizeFollow every link and print the final absolute path
-e / --canonicalize-existingLike -f, but every part must exist
-m / --canonicalize-missingLike -f, even if parts do not exist
-n / --no-newlineNo newline at the end (handy in scripts)

Examples

  • $ readlink /usr/bin/python3

    See which version python3 points to

    Explain
  • $ readlink -f ./config

    The final real path

    Explain

Related