I can print current directory using pwd, but this gives me the path I navigated to get to where I am. I need to know which disk/partition current directory is on.

For example, if I create symlink user@pc:~$ ln -s /media/HD1 hard_disk and then navigate to ~/hard_disk and run pwd it will print /home/user/hard_disk.

I would like to get the actual path I'm currently on or better just the actual filesystem I'm currently on, which corresponds to one in df.


2 Answers 2


pwd -P will give you the physical directory you are in, i.e. the pathname of the current working directory with the symbolic links resolved.

Using df . would give you the df output for whatever partition the current directory is residing on.

Example (on an OpenBSD machine):

$ pwd
$ pwd -P
$ df .
Filesystem  512-blocks      Used     Avail Capacity  Mounted on
/dev/sd3a    103196440  55987080  42049540    57%    /extra

To parse out the mountpoint from this output, you may use something like

$ df -P . | sed -n '$s/[^%]*%[[:blank:]]*//p'

To parse out the filesystem device used, use

$ df -P . | sed -n '$s/[[:blank:]].*//p'

I believe some Linux systems also supports

findmnt --target .

(where --target . can be replaced by -T .) or, for more terse output,

findmnt --output target --noheadings --target .

(where --noheadings may be replaced by -n, and --output target may be replaced by -o target) to get the mountpoint holding the filesystem that the current directory is located on.

Use --output source to get the mounted device node.

  • "To parse out the filesystem device used, use" ...unless you're on a system that uses ZFS, at which point that will print the ZFS file system name. So you'd get something like tank/data/whatever/someplace back, where tank is the pool name. (At that point you could map it back to a pool, and from there to a set of candidate disks, but I'm pretty sure there's no direct way to map it back to "a" disk.)
    – user
    Apr 2, 2019 at 12:46

As said by Ignacio here, you can use df -P file/goes/here | tail -1 | cut -d' ' -f 1 .

Not the answer you're looking for? Browse other questions tagged .