Signup/Sign In

How to access Windows Files in other drive using Cygwin?

Posted in Tricks   LAST UPDATED: AUGUST 24, 2021

    Cygwin is a large collection of GNU and Open Source tools which provide functionality similar to the Linux operating system on Windows machine. Mnay developers around the globe use Cygwin, because it is easy to install & setup and can be used to run shell scripts and other Linux distribution functionalities.

    But Cygwin comes with its own struggle which arise because of the drives created by Windows. Many developers face issue in moving around using the cygwin command line.

    Although the basic cd command works in cygwin to move to various directories. You cannot simple write cd D: to move to the D drive or any other drive for that matter.

    Following command can be used to navigate to other drives outside the cygwin home directory,

    cd /cygdrive/c

    Similarly, if you want to navigate to some other drive, you can do so by simply changing /cygdrive/c to /cygdrive/d for D drive.

    Checking all the available drives

    You can look for the available drives in a Windows machine by running the following command,

    df -h

    You will get an output like this,

    Filesystem Size Used Avail Use% Mounted on
    C:/cygwin64 200G 72G 129G 36% /
    D: 277G 25G 253G 9% /cygdrive/d

    Creating a Shortcut

    If you want to create a simple command to navigate through drives you can create an alias for the cygdrive command, by creating a soft link like this,

    ln -s /cygdrive/c /c

    This command will create a symbolic soft link to /cygdrive/c to a new file /c in your home.

    Hope this short article helps you in smoothly navigating to different directories while using cygwin on Windows machine.

    You may also like:

    About the author:
    I like writing content about C/C++, DBMS, Java, Docker, general How-tos, Linux, PHP, Java, Go lang, Cloud, and Web development. I have 10 years of diverse experience in software development. Founder @ Studytonight
    Tags:HowToCygwin
    IF YOU LIKE IT, THEN SHARE IT
     

    RELATED POSTS