Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So I have created a bunch of symbolic links to top of source code tree, data directories, etc

How do I, from command line, cd to these links?

share|improve this question

migrated from Jun 15 '11 at 15:34

This question came from our site for professional and enthusiast programmers.

up vote 7 down vote accepted

Are you sure you actually created symbolic links, or did you create a Windows Shortcut? Those are not links, and don't work as such. Actual symbolic links behave like other directories, so if you are unable to cd into it, either you a) don't have permissions to enter the target directory, b) the symlink doesn't point to a valid directory, or c) it's actually not a symlink.

(If you want to create NTFS symlinks, use the MKLINK command)

As a parable, imagine a river and its tributaries: all those rivers flow into the large river; that is the directory structure; riverside towns are files. Now, a Windows Shortcut is just a sign on the riverbank: "it's not here, you need to go back down to Mississippi and then up Ohio, it is five miles upstream, on the left bank" - but you need to read English to understand it (have a program which handles this for you, e.g. Explorer.exe). A symlink is like a water canal: if you follow it, it will actually take you someplace else, no matter whether you can read English or not (no matter what program you use).

share|improve this answer
same thing as downloads folder shortcut? I thought that is the way you create a symbolic link in Windows 7 – reza Jun 15 '11 at 15:49
shortcut != symbolic link : "shortcuts" are just regular files with content "see that other thing over there", and they are handled by the shell (Explorer.exe, pretty much a normal program). "symbolic links" are special data structures in the NTFS structure, which make a directory accessible from an alternate location; they are handled internally, rather deep in the OS. – Piskvor Jun 15 '11 at 15:51
No; shortcuts are not symlinks. – SLaks Jun 15 '11 at 15:51
@reza: As to "how to create symbolic links in Windows", see that link I posted. – Piskvor Jun 15 '11 at 15:56
@reza: As you are using Windows 7, it's the mklink command which you need to use, and not junction as mentioned in the answer, which is is for 2000/XP/2003. mklink can be used to make junctions as well as symbolic links. – paradroid Jun 15 '11 at 17:39

Symbolic links are normal directories.
You can CD into them just like any other directory.

share|improve this answer
I have a link called: code – reza Jun 15 '11 at 15:43
I have a link called: code, you are saying just type cd code. If that is what you are saying, it is not working. – reza Jun 15 '11 at 15:43
Why not? What happens? – SLaks Jun 15 '11 at 15:44
Are you sure you aren't talking about shortcuts? – SLaks Jun 15 '11 at 15:44
the error is the same as any non existent path. System can not find the path specified is the error – reza Jun 15 '11 at 15:48

Example: Target folder is d:\code\ , I made a shortcut (rightclick-drag-drop) to it in C:\

see snapshot: enter image description here

The 'shortcut' is an .lnk file which has the target path (D:\code)and a bunch of other junk in it ie. computer name (kandalf) and god knows what else.

You could parse the .lnk file and use the path inside it.
Google for 'parse .lnk file ' (in C/VB/Whatever you preffer) or '.lnk file format'

Too much trouble? why not use full paths in your config file/whatever it is you're doing? ;)

As a last resort I'd go for NTFS Junctions... Last resort because, the windows file manager is stupid, ie. when you delete a junction it doesn't just delete the junction; it deletes the junction AND the target folder and all it's files! Now think of that junction sitting under a deep directory structure in an obscure folder that you later want to delete -- yup you guessed it!

share|improve this answer
@DMB: Explorer in Vista and newer are junction-aware. Deleting a junction will only delete the junction itself, not the target. – afrazier Jun 15 '11 at 17:31
Finally! good to know, thanks ;) – DM8 Jun 15 '11 at 19:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .