Tag Info

Hot answers tagged

19

Jim's answer explains how to test for a symlink: by using test's -L test. But testing for a "hard link" is, well, strictly speaking not what you want. Hard links work because of how Unix handles files: each file is represented by a single inode. Then a single inode has zero or more names or directory entries or, technically, hard links (what you're calling ...


11

An example: $ touch f1 $ ln f1 f2 $ ln f1 f3 $ ln -s f1 s1 $ ln -s f2 s2 $ ln -s ./././f3 s3 $ ln -s s3 s4 $ ln s4 s5 $ ls -li total 0 10802124 -rw-r--r-- 3 stephane stephane 0 Nov 12 19:55 f1 10802124 -rw-r--r-- 3 stephane stephane 0 Nov 12 19:55 f2 10802124 -rw-r--r-- 3 stephane stephane 0 Nov 12 19:55 f3 10802345 lrwxrwxrwx 1 stephane stephane 2 Nov 12 ...


9

Using the -h and -L operators. -h file true if file is a symbolic link -L file true if file is a symbolic link http://www.mkssoftware.com/docs/man1/test.1.asp According to this SO thread, they have the same behavior, but -L is preferred.


3

Yes, your shell tries to be smart on changing to a symlink directory: $ mkdir a $ ln -s a b $ cd b $ pwd /home/michas/b $ pwd -P /home/michas/a After changing to symlink b your shell pretends you are really in "directory" b but instead the symlink sent you to directory a. See help pwd: -P print the physical directory, without any symbolic links ...


3

This should do it: cd /volume1/Drive/Series ln -s ../SeriesPC/* .


3

There is no problem if you use only relative symlinks within this volume. ln -s ../otherdir/otherfile link


2

ln -sf --no-target-directory /path/to/new/dir link The option --no-target-directory (aka -T) prevents a new symlink to be created in the linked directory but is only available on GNU systems. On FreeBSD or Apple OS/X, you'd use: ln -sF /path/to/new/dir link


2

That way you can start the program without extending the search path ($PATH) in which the shell searches for binaries/executables, and also without copying the them in the /usr/bin directory (or other directory in $PATH). This has minor space advantages (if /opt and /usr are on different partitions), but more importantly the so linked executable, can follow ...


2

Try this : readlink -f /path/file ( last target of your symlink if there's more than one level ) If you just want the next level of symbolic link, use : readlink /path/file


1

The $PATH environment variable is only used when you run an executable. In your case, you've symlinked a directory. As a directory isn't an executable, then your shell will not search $PATH for it. If you symlink to an executable, you'll find that it works as expected.


1

There are a few problems with your command. You ran ln -s /media/Schijf-2/Nel/Mijn Documenten/ ./home/nel/Documenten This means "create a link called Documenten that points to /media/Schijf-2/Nel/Mijn Documenten/. Because of the space, the ln command was given Documenten and not ./home/nel/Documenten as a target. One of way of dealing with this is to ...


1

You can get the real path, with links resolved using realpath and compare the output realpath ../../../../.. cd ../../../../.. realpath . On my system: ~/shared $ realpath .. /home/avdndata/lnk ~/shared $ cd .. ~ $ realpath . /home/anthon


1

I would do the following if you want all the files/directories under SeriesPC to be linked: cd /volume1/Drive/SeriesPC for i in * ; do ln -s "$PWD/$i" /volume1/Drive/Series/ ; done If not everything under SeriesPC should be linked make sure you can find just the directories that you need e.g. using find * -maxdepth 1 -type d and then do: cd ...



Only top voted, non community-wiki answers of a minimum length are eligible