readlink

The readlink command in Linux is used to print the target of a symbolic link. This can be useful to determine the actual file or directory that a symbolic link points to.

The readlink command is used in the following syntax:

readlink [options] [symlink]

The symlink is the symbolic link to print the target of.

The options can be used to specify the following:

  • -f : Follow symbolic links recursively.

  • -n : Print the target of the symbolic link without trailing slashes.

For example, to print the target of the symbolic link mylink, you would run the following command:

readlink mylink

This command will print the target of the symbolic link mylink.

To follow symbolic links recursively and print the target of the last symbolic link, you would run the following command:

readlink -f mylink

This command will follow all symbolic links in the path of the symbolic link mylink and print the target of the last symbolic link.

To print the target of the symbolic link mylink without trailing slashes, you would run the following command:

readlink -n mylink

This command will print the target of the symbolic link mylink without trailing slashes.

The readlink command is a versatile tool that can be used to determine the target of a symbolic link. It is a simple command to use and is supported by most Linux distributions.

Here are some additional things to note about the readlink command:

  • The readlink command can be used to determine the target of a symbolic link.

  • The readlink command can be used to follow symbolic links recursively.

  • The readlink command can be used to print the target of a symbolic link without trailing slashes.

  • The readlink command is a simple command to use and is supported by most Linux distributions.

help

Last updated