Tag Info

Hot answers tagged

14

With POSIX shell, you can use -P option of cd builtin: cd -P <link> With bash, from man bash: The -P option says to use the physical directory structure instead of following symbolic links (see also the -P option to the set builtin command)


8

A symlink actually stores the path you give literally, as a string¹. That means your link ~/mylink contains "." (one character). When you access the link, that path is interpreted relative to where the link is, rather than where you were when you made the link. Instead, you can store the actual path you want in the link: ln -s "$(pwd)" ~/mylink using ...


7

which 2 commands? /usr/bin/java is a soft (symbolic) link to /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/bin/java There is no difference as they are the same file. If you type something like ls -l /usr/bin/java You might get a result such as: lrwxrwxrwx. 1 root root 22 Aug 5 17:01 /usr/bin/java -> /etc/alternatives/java Which would mean ...


5

GNUly: find . -lname '/foo*' -printf '%p\0%l\0' | awk -vRS='\0' ' { getline target sub("^/foo", "/bar", target) printf("%s\0%s\0", target, $0) }' | xargs -r0n2 ln -sfT Or with recent GNU sed: find . -lname '/foo*' -printf '%l\0%p\0' | sed -z 's|^/foo|/bar|;n' | xargs -r0n2 ln -sfT Beware that you will potentially be ...


4

Shells keep track of symbolic links in the path to the current directory (this is known as logical current directory tracking). If you want to expand all symbolic links, pass the option -P to the cd builtin (for physical current directory tracking): cd -P logic If you're in a directory which you've accessed via a symbolic link and want to switch the ...


3

As you have said, directory hard links are not possible. Perhaps you could move the original directory to a different location, such as a hidden folder, and make both of your directories soft links to the real location. That way you could rename them freely, and the links would still be valid. This shell alias may help: function mkdirlink { ...


3

You can use readlink to determine where your link points, and provide this output as the target of your cd. cd "$(readlink <link>)" In the case of additional symlinks pointing to symlinks, readlink will simply provide the target, unless you specify one of it's options to follow symlinks to a canonical file target, for example readlink -f ...


3

What is the advantage to keep symbolic links relative to directory? Because this allows one to move the direcoty itself without breaking the symbolic links? Exactly. In addition, is it possible to create a symbolic link with .. (parent directory) in the path without being in the directory? ln -sv '/etc/init.d/rsyslog' '/etc/rc3.d/../init.d/rsyslog' ...


3

readlink -f will: canonicalize a path by following every symlink in every component of the given name recursively; all but the last component must exist which will search: for an executable or script in the directories listed in the environment variable PATH using the same algorithm as bash(1) which doesn't care whether what it finds is a ...


2

Does "allowed storage of the target path within the data structures used for storing file information on disk (inodes)" mean that a fast symlink stores the path of the linked file inside the inode of the fast symlink Yes Does a fast symlink, as a file itself, actually only have an inode and has no file content? Depends what you mean by "has file ...


2

The syntax of ln may seem counter-intuitive at first until you see the rationale behind it. The syntax (for soft link creation) is ln -s <TARGET> <LINK_NAME> where <TARGET> is interpreted relative to the location of the soft link. So when you say something like: ln -s file1.txt /home/user9000/Desktop/SymbolicLink.txt This means ...


1

Your link is incorrect. You need: ln -s "$PWD/file1.txt" /home/user9000/Desktop/SymbolicLink.txt You can also create a relative link (starting with ../), but I suggest that you cd to /home/user9000/Desktop first to avoid making a mistake.


1

In the following, LABEL can be anything you want, /dev/sdb1 is the partition you create and choose to use on your new HDD and /var/www/myfiles is where your files are currently located. Alter these to suint your scenario. Partition the new HDD. You can have one partition that takes up the whole disk, or make a smaller partition which leaves you space on ...


1

You should use: ln -s "$(cd . && pwd)" ~/mylink or: ln -s "$(pwd -P)" ~/mylink to get the right result for current working directory. It can be changed while you was working in it as in this question.


1

From the linked inode wiki page: A file system relies on data structures about the files, beside the file content. The former is called metadata—data that describes data. Each file is associated with an inode, which is identified by an integer number, often referred to as an i-number or inode number. Inodes store information about files and ...


1

It is possible for a process to interrogate the file system to determine its current working directory, using a method that’s a little too complicated to be on topic as an answer to this question.  This is what the pwd program and the getcwd library function do.  In the early days of Unix, they were the only ways to find out what your working directory was.  ...


1

try do some example, your system supports chained symlinks, for example cd ln -s /bin/ls myls1 ln -s myls1 myls2 ln -s myls2 myls3 start experiment: ./myls1 should work ./myls2 works or not? ./myls3 works or not? When myls3 works, your system supports chained symlinks. I don't belive it doesn't :) Then I think problem is not with symlinks, but with ...



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