How to find out which partition a File Belongs to In Linux

How do we find out which file are belongs to which partition on Linux Operating System?

I think all of us are Familiar with the Command DF

The df command displays information about total space and available space on a file system. The FileSystem parameter specifies the name of the device on which the file system resides, the directory on which the file system is mounted, or the relative path name of a file system. Try it as follows:

df -k $HOME
df -k /tmp
df -m /path/to/dir

The syntax is as follows:

df /path/to/directory
df /path/to/file

In this example find out partition name for a file called /home/johnson/, enter:

$ df -T

Sample outputs:

The above command indicates that the file called “/home/johnson/” belongs to /dev/vda1 partition. The following command only shows partition name:

df /home/johnson/ | awk '/^/dev/ {print $1}'


awk '/^/dev/ {print $1}' <<<"$(df /home/johnson/"

Sample outputs:


0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *