Linux: Find Out What Partition a File Belongs To

Linux: Find Out What Partition a File Belongs To

To find out what partition a file belongs to on a Linux system, you can use the df command with the -h option to display the file system usage in a human-readable format, and then specify the file as an argument.

For example, to find out what partition the file /etc/hosts belongs to, you can use the following command:

df -h /etc/hosts
Source:‮ww‬w.lautturi.com

This will display the file system usage for the partition that contains the file /etc/hosts, along with the mount point, capacity, used space, and available space.

You can also use the findmnt command with the --target option to display the file system that a file belongs to. For example:

findmnt --target /etc/hosts

This will display the file system that contains the file /etc/hosts, along with the mount point, file system type, and other information.

Keep in mind that these commands may not work correctly if the file is a symbolic link, or if the file system that contains the file is not mounted. In these cases, you may need to use other techniques to determine which partition a file belongs to.

For more information about how to find out what partition a file belongs to on a Linux system, you can consult the documentation for the df and findmnt commands or seek assistance from a qualified Linux administrator.

Created Time:2017-10-30 10:17:44  Author:lautturi