To find the absolute pathname of a command or file in Linux, you can use the realpath
command. For example:
realpath /usr/bin/ls
This will print the absolute pathname of the ls
command, which is /usr/bin/ls
.
You can also use the which
command to find the absolute pathname of a command. For example:
which ls
This will print the absolute pathname of the ls
command, as well as the name of the shell that will execute it.
If you want to find the absolute pathname of a file, you can use the readlink
command. For example:
readlink -f /etc/passwd
This will print the absolute pathname of the /etc/passwd
file, which is typically /etc/passwd
.
You can also use the realpath
command to resolve symbolic links and find the actual location of a file or directory. For example:
realpath /etc/alternatives/ls
This will print the absolute pathname of the file or directory that the symbolic link /etc/alternatives/ls
points to.