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.
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.
- readlink -f: This option canonicalize by following every symlink in every component of the given name recursively; all but the last component must exist.
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.
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.
readlink -m desk3
- readlink -n : This option will do not output the trailing delimiter.
readlink -n desk4
- readlink -q: This option will execute in quiet mode.
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.
readlink -s desk5
- readlink -v : This option will report error messages if any.
readlink -v desk6
- readlink -z : This option will end each output line with NUL, not newline.
readlink -z desk2
- readlink –help : This option will display this help and exit.
- readlink –version : This option will show the version information and exit.