What is the windows equivalent to the ln -s <target folder> <link folder> unix symbolic link command?

丶灬走出姿态 提交于 2019-12-04 08:21:01
Gauthier Boaglio

Try this :

mklink /D .\ venv\lib\python2.7\site-packages\httplib2

Note : mklink [OPTION] LINK TARGET (link and target are flipped compared to linux's ln -s)

Mklink Command Syntax :

MKLINK has 3 options /D, /H and /J. You also need to specify the path to the new symbolic link and the path to the original file or directory.

/D – used to create symbolic links for directories (d for directory)

/H – used to create hard links (h for hard link)

/J – used to create directory junction (j for junction)

By the way, always prefer mklink /D over mklink /J. Windows explorer will delete the entire contents of a junction (the latter) whereas when deleting a directory link (the former) it will just remove the link.

The dot . is the current directory (from where you are running the command). In the example above, I changed it to .\ to make it explicit.

For files : Helpful link.

If you can't get privilege with /D, use a hard link (option /H) :

mklink /H .\six.py venv\lib\python2.7\site-packages\six.py

'.' stands for the current folder, in both *nix-land and Windows. So those commands are making symbolic links right then and there.
These would be the same as saying:

ln -s venv/lib/python2.7/site-packages/twilio twilio

Or in Windows (Vista, 7, 2008 and up):

mklink /d twilio venv\lib\python2.7\site-packages\twilio 

where

  • twilio is the target or link to create
  • venv\lib\python2.7\site-packages\twilio is the source directory

Remember that mklink has the opposite soure | target syntax that ln -s has.

ln is source -> target
mklink is target -> source

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!