Search code examples
pythonlinuxln

How do I link directories in python (Linux cmd ln -s equivalent)?


I'm translating Linux commands to a python script. How would I perform the Linux command 'ln -s'

CMD:

    ln -s /users/me/link_file hello 

I want to link 'hello' to 'link_file' in python

Thanks!


Solution

  • os.symlink() is the provided function for creating symlinks. They are created as such:

    import os
    os.symlink(src,dst)
    

    Where src and dst are the paths.

    See the documentation here for more info.