Open In App

readlink command in Linux with Examples

Improve
Improve
Like Article
Like
Save
Share
Report

readlink command in Linux is used to print resolved symbolic links or canonical file names. In simple words whenever we have a symbolic link and we want to know what path it represents. Then, in that case, the readlink command comes into play to show the actual path of the symbolic link.

Syntax:

readlink [OPTION]... FILE...

Example: It will print the print resolved symbolic links or canonical file names of the symbolic link passed with the command as shown below.

Explanation: As you can see in the above example we have a symbolic link with the name of the desk with the help of readlink command we will be able to identify its actual path.

Options:

  • readlink -f: This option canonicalize by following every symlink in every component of the given name recursively; all but the last component must exist.

    Example:

    readlink -f desk1

  • readlink -e: This option will canonicalize by following every symlink in every component of the given name recursively, all components must exist.

    Example:

    readlink -e desk

    Explanation: This option is similar to -f option the only difference between -f and -e option is in -e, all components must exist and in -f, the last component must exist.

  • readlink -m : This option canonicalize by following every symlink in every component of the given name recursively, without requirements on components existence.

    Example:

    readlink -m desk3

  • readlink -n : This option will do not output the trailing delimiter.

    Example :

    readlink -n desk4

  • readlink -q: This option will execute in quiet mode.

    Example:

    readlink -q desk

    Explanation: With the help of this option the user can read the symbolic links in every component and nothing like errors is being displayed on the console.

  • readlink -s : This option will suppress most error messages.

    Example:

    readlink -s desk5

  • readlink -v : This option will report error messages if any.

    Example:

    readlink -v desk6

  • readlink -z : This option will end each output line with NUL, not newline.

    Example:

    readlink -z desk2

  • readlink –help : This option will display this help and exit.
    readlink --help

  • readlink –version : This option will show the version information and exit.
    readlink --version


Last Updated : 10 Apr, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads