How do you unlink a symlink created with Microsoft's linkd.exe tool? - symlink

I'm using Microsoft linkd.exe tool to create symlinks, but then I typed linkd -d and it created a link called "-d"
now I cant remove "-d"
LOL this sucks.
So i renamed it to ddd so it wouldnt think it was an option.
But I still need to know how to unlink things =/

This makes it appear that the contents of the bar directory is inside the foo directory:
linkd foo bar
And this breaks the link:
linkd foo /D
You have to be careful, as some actions delete the contents of bar instead of breaking the link. For example, don't delete things.

no actually you have to use the linkd.exe tool still. del {linkfile} remove all the content at the source =/ oops!
linkd /d

Related

How to move up multiple folder

Using VS Code terminal, a certain directory keeps popping up as default :
C:\Users\user\name\folder1\folder2\folder3\folder4
How do move back up with one single command instead of doing multiple "cd ../.."
Much appreciated!
Sorry I am answering for CMD as it was tagged CMD, I'm not sure how this affects VSCode. So, I'm not sure if I should just delete this or if it is actually relevant. Please let me know.
What folder do you want to go to?
Using your Example C:\Users\user\name\folder1\folder2\folder3\folder4
If you would like to go to the root CD \ will do.
If you would like to go up 4 directories CD ..\..\..\.. will do
If you want to go up 4 directories and back down 3 CD ..\..\..\..\folder1\folder2\folder3
If you want to always go to a specific directory on the current disk CD \Path\to\directory
If you want to always go to a specific folder on another disk CD /D DriveLetter:\Path\To\Folder (eg CD /D X:\Path\To\Folder)
In VScode, add the exact folder in Workspace, you want to open terminal from.

recursive rm -rf of a symlink ?

I think I know the answer to this one but I'll ask anyway.
I created a symlink to a dir on a different disk. A script (which I have no control over) will "rm -rf *" in the dir that has this symlink. It deletes the symlink OK, but leaves the target dir on the other directory. I expected this but want to make sure that there's no way I can create the symlink somehow to behave like a hard link in terms of making "rm -rf " recursively delete the dir on the other disk. -T looked kind of promising, but didn't pan out. Again, I have no control over the rm command execution. But I do create the target dir on the other disk, plus I create the symlink to it..
Thanks in advance!
What you are essentially asking is can a hard link be created across file systems. The answer is, they cannot. This tutorial confirms this:
An important thing to note about hard links is that they only work on the current file system. You can not create a hard link to a file on a different file system. To do that you need to use symbolic links, Section 1.4.3.
As you seem to already understand, removing a softlink will have no effect on the the thing it is linked to. This is true for hardlinks as well.

How do I Copy a directory and contents to the same location with a new name

I am going to answer this question myself to get the information out there because I was unable to find the answer on google. I need to run a command that will copy folder foo to the same location as foo and have it be named bar. (see images below)
I tried several variations of the copy command and copy to another location rename then move back, but this was too complex for my taste. Please feel free to expand on my answer if I am missing something.
Thanks
Not saying this is perfect, but this is what worked for me
#first move to the desired working directory
cd C:\temp
#then run the following command using exactly the syntax below
xcopy .\foo .\bar\
This is what worked for me.

Is there a way to go two directories back in cygwin (linux)?

I know that you can go back one directory in cygwin by using the dash (-). But, how do you go back more than one directory in your history?
I've tried cd -- it doesn't seem to work. Thanks! This would be very very helpful.
You can use pushd and popd. pushd adds a directory to stack, popd removes it. See man bash for details.
Only previous dir is remembered, so Hunle's answer or some other way of remembering dirs is needed.

Bookmark Directories In Terminal

Looking for a solution to quickly navigate to long paths in a shell (particularly Max OS X Terminal.app).
Say my path is ~/This/Is/A/Really/Long/Path/That/I/Would/Rather/Not/Type/Frequently
Instead of cd ~/This/Is/A/....
I would like to be able to store favorites/bookmark directories so I could do "cd myPath"
Are there any binaries or tools available to do something like this?
I've found the packages 'Apparix' and 'Goto' which together make the stuff dreams are made of for us terminal junkies.
Naturally, I had trouble installing Apparix, but I figured it out in the end.
How To Install Apparix on Mac OS X:
Download the tarball from Apparix's homepage.
Unpack the tarball, cd to the unpacked folder.
Run this command ./configure --prefix=$HOME/local && make && make install.
Run man apparix, scroll down to the heading BASH-style functions, copy everything within that section (delimited with ---) and paste it into ~/.bash_profile.
That's it. You should now have Apparix up and running on OS X (further install info and usage is on Apparix's homepage).
Another solution is to use Bashmarks, which allows you to this
$ cd ~/This/Is/A/Really/Long/Path/That/I/Would/Rather/Not/Type/Frequently
$ s shortname # save current path as `shortname`
$ cd /
$ g shortname # cd to ~/This/Is/A/Really/Long/Path/That/I/Would/Rather/Not/Type/Frequently
You can use aliases (stick them in your ~/.bash_profile if you want them to always load)
alias cd_bmark1='cd ~/This/Is/A/Really/Long/Path/That/I/Would/Rather/Not/Type/Frequently'
Then use by just typing
cd_bmark1
into the console
I know you already found an answer that worked for you, but a couple of more lightweight suggestions that might help others looking for similar things
If your directories are relatively fixed, just long and far away from each other, you can use the CDPATH environment variable to add directories to the search path when typing the "cd" command. If the directory name you try to cd to isn't in the current directory, the other entries in your CD path will also be looked at (and it's also tab complete aware, at least in bash and zsh).
Switching to zsh rather than bash and using the excellent directory stacks abilities. With it, you can maintain a history of directories that you've visited, view the history with the "dh" alias, and easily switch to a directory by using quick shortcuts (ex: cd -3 to switch to the 3rd directory in your history stack).
Why not having a symlink ?
ln -s ~/This/Is/A/Really/Long/Path/That/I/Would/Rather/Not/Type/Frequently bmark
cd bmark
I use to.sh daily to create and navigate bookmarked paths in bash. It supports tag autocompletion and the ability to easily add/remove bookmarks.
https://github.com/Grafluxe/to.sh
Full disclosure, I wrote this tool :)

Resources