How do I find which disk/partition current directory is on? [duplicate]





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







5
















This question already has an answer here:




  • Determine what device a directory is located on

    4 answers




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.










share|improve this question









New contributor




Rizhiy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











marked as duplicate by don_crissti, Community Apr 2 at 15:50


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • 1





    What should the output be for a filesystem that does not live on a partition? What should the output be for a union filesystem that is the union of multiple different filesystems that may live on different partitions (or no partitions at all)?

    – Jörg W Mittag
    Apr 2 at 13:55











  • Related unix.stackexchange.com/q/508420/255251

    – Prvt_Yadv
    Apr 2 at 14:07











  • Possible duplicate of Determine what device a directory is located on or How do I find on which physical device a folder is located? etc... plenty of duplicates but nobody wants to search. Nobody.

    – don_crissti
    Apr 2 at 14:16








  • 1





    @don_crissti The duplicate answers do not mention pwd -P, but ok.

    – Kusalananda
    Apr 2 at 16:02




















5
















This question already has an answer here:




  • Determine what device a directory is located on

    4 answers




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.










share|improve this question









New contributor




Rizhiy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











marked as duplicate by don_crissti, Community Apr 2 at 15:50


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • 1





    What should the output be for a filesystem that does not live on a partition? What should the output be for a union filesystem that is the union of multiple different filesystems that may live on different partitions (or no partitions at all)?

    – Jörg W Mittag
    Apr 2 at 13:55











  • Related unix.stackexchange.com/q/508420/255251

    – Prvt_Yadv
    Apr 2 at 14:07











  • Possible duplicate of Determine what device a directory is located on or How do I find on which physical device a folder is located? etc... plenty of duplicates but nobody wants to search. Nobody.

    – don_crissti
    Apr 2 at 14:16








  • 1





    @don_crissti The duplicate answers do not mention pwd -P, but ok.

    – Kusalananda
    Apr 2 at 16:02
















5












5








5









This question already has an answer here:




  • Determine what device a directory is located on

    4 answers




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.










share|improve this question









New contributor




Rizhiy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.













This question already has an answer here:




  • Determine what device a directory is located on

    4 answers




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.





This question already has an answer here:




  • Determine what device a directory is located on

    4 answers








shell






share|improve this question









New contributor




Rizhiy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Rizhiy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Apr 2 at 14:05







Rizhiy













New contributor




Rizhiy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Apr 2 at 10:38









RizhiyRizhiy

285




285




New contributor




Rizhiy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Rizhiy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Rizhiy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




marked as duplicate by don_crissti, Community Apr 2 at 15:50


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by don_crissti, Community Apr 2 at 15:50


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 1





    What should the output be for a filesystem that does not live on a partition? What should the output be for a union filesystem that is the union of multiple different filesystems that may live on different partitions (or no partitions at all)?

    – Jörg W Mittag
    Apr 2 at 13:55











  • Related unix.stackexchange.com/q/508420/255251

    – Prvt_Yadv
    Apr 2 at 14:07











  • Possible duplicate of Determine what device a directory is located on or How do I find on which physical device a folder is located? etc... plenty of duplicates but nobody wants to search. Nobody.

    – don_crissti
    Apr 2 at 14:16








  • 1





    @don_crissti The duplicate answers do not mention pwd -P, but ok.

    – Kusalananda
    Apr 2 at 16:02
















  • 1





    What should the output be for a filesystem that does not live on a partition? What should the output be for a union filesystem that is the union of multiple different filesystems that may live on different partitions (or no partitions at all)?

    – Jörg W Mittag
    Apr 2 at 13:55











  • Related unix.stackexchange.com/q/508420/255251

    – Prvt_Yadv
    Apr 2 at 14:07











  • Possible duplicate of Determine what device a directory is located on or How do I find on which physical device a folder is located? etc... plenty of duplicates but nobody wants to search. Nobody.

    – don_crissti
    Apr 2 at 14:16








  • 1





    @don_crissti The duplicate answers do not mention pwd -P, but ok.

    – Kusalananda
    Apr 2 at 16:02










1




1





What should the output be for a filesystem that does not live on a partition? What should the output be for a union filesystem that is the union of multiple different filesystems that may live on different partitions (or no partitions at all)?

– Jörg W Mittag
Apr 2 at 13:55





What should the output be for a filesystem that does not live on a partition? What should the output be for a union filesystem that is the union of multiple different filesystems that may live on different partitions (or no partitions at all)?

– Jörg W Mittag
Apr 2 at 13:55













Related unix.stackexchange.com/q/508420/255251

– Prvt_Yadv
Apr 2 at 14:07





Related unix.stackexchange.com/q/508420/255251

– Prvt_Yadv
Apr 2 at 14:07













Possible duplicate of Determine what device a directory is located on or How do I find on which physical device a folder is located? etc... plenty of duplicates but nobody wants to search. Nobody.

– don_crissti
Apr 2 at 14:16







Possible duplicate of Determine what device a directory is located on or How do I find on which physical device a folder is located? etc... plenty of duplicates but nobody wants to search. Nobody.

– don_crissti
Apr 2 at 14:16






1




1





@don_crissti The duplicate answers do not mention pwd -P, but ok.

– Kusalananda
Apr 2 at 16:02







@don_crissti The duplicate answers do not mention pwd -P, but ok.

– Kusalananda
Apr 2 at 16:02












2 Answers
2






active

oldest

votes


















9














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
/usr/ports




$ pwd -P
/extra/ports




$ 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'
/extra


To parse out the filesystem device used, use



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


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.






share|improve this answer


























  • "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.)

    – a CVn
    Apr 2 at 12:46





















0














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






share|improve this answer








New contributor




The Coding Penguin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    9














    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
    /usr/ports




    $ pwd -P
    /extra/ports




    $ 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'
    /extra


    To parse out the filesystem device used, use



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


    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.






    share|improve this answer


























    • "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.)

      – a CVn
      Apr 2 at 12:46


















    9














    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
    /usr/ports




    $ pwd -P
    /extra/ports




    $ 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'
    /extra


    To parse out the filesystem device used, use



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


    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.






    share|improve this answer


























    • "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.)

      – a CVn
      Apr 2 at 12:46
















    9












    9








    9







    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
    /usr/ports




    $ pwd -P
    /extra/ports




    $ 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'
    /extra


    To parse out the filesystem device used, use



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


    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.






    share|improve this answer















    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
    /usr/ports




    $ pwd -P
    /extra/ports




    $ 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'
    /extra


    To parse out the filesystem device used, use



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


    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.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Apr 2 at 11:34

























    answered Apr 2 at 10:51









    KusalanandaKusalananda

    140k17261435




    140k17261435













    • "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.)

      – a CVn
      Apr 2 at 12:46





















    • "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.)

      – a CVn
      Apr 2 at 12:46



















    "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.)

    – a CVn
    Apr 2 at 12:46







    "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.)

    – a CVn
    Apr 2 at 12:46















    0














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






    share|improve this answer








    New contributor




    The Coding Penguin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.

























      0














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






      share|improve this answer








      New contributor




      The Coding Penguin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.























        0












        0








        0







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






        share|improve this answer








        New contributor




        The Coding Penguin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.










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







        share|improve this answer








        New contributor




        The Coding Penguin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        share|improve this answer



        share|improve this answer






        New contributor




        The Coding Penguin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        answered Apr 2 at 11:12









        The Coding PenguinThe Coding Penguin

        11




        11




        New contributor




        The Coding Penguin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.





        New contributor





        The Coding Penguin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






        The Coding Penguin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.















            Popular posts from this blog

            Plaza Victoria

            In PowerPoint, is there a keyboard shortcut for bulleted / numbered list?

            How to put 3 figures in Latex with 2 figures side by side and 1 below these side by side images but in...