e Learning

How to get Absolute Path of a File in Linux

In this Tutorial we are going to learn how to get Absolute Path or Full Path of a File in Linux Operating System.

You can get absolute path or full path of a file in Linux using readlink command with -f option.

readlink -f filename

It is also possible to provide directory as the argument not just files.

I have a file called smb.conf in my current working directory, Now i want to get the full path of the smb.conf file.

readlink -f smb.conf


absolute path linux

As above image shows, readlink command tells that /etc/samba/smb.conf is the Absolute Path of the smb.conf file.

Get the Path of a Symbolic Link

Linux readlink command can be also used to find where a symlink is pointing to.

readlink -f link-name

If you Only want to get the full path of the folder without the file name, use pwd command. Pwd command will print your current working directory.