Tag Info

New answers tagged

0

Here's a tiny test set: mkdir ./tmp1 ./tmp2 touch ./tmp1/file1 ./tmp2/file2 ln -s ./tmp1 ./tmp3 ls -H ./tmp3 OUTPUT file1 So now I'll... mount --bind ./tmp2 ./tmp1 ls -H ./tmp3 OUTPUT file2 tada! Now all links that once pointed to ./tmp1 will automatically point to ./tmp2 - as, in fact, so does ./tmp1 because they are the same mountpoint. Had ...


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 ...


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 ...


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

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

its depend to where is your terminal path ? if you are in base dir ($)do this : ln -s file1.txt Desktop/ if not go to base dir with cd command . and do that ! and as you say in comment if you are the dir in do this : so do this ln -s file1.txt SymbolicLink.txt


-1

Yes, the UI behaves differently. A softlink won't be shown as a icon in desktop. You need to copy and paste the file there or create a link using the graphical interface itself.


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

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 ...


0

Store the common files with a owner unknown to any of the users. (some admin user). When userA is downloading a common file, change the ownership of the file from admin to userA. By this way, userA will assume he is the owner of the file. After the file download is complete, revert back the permission of file to admin user.


0

lrwxr-xr-x 1 jsw staff 6 1 Aug 13:54 /Users/jsw/.vimrc -> .vimrc You've made a mistake; this was produced by the equivalent of: ln -s .vimrc .vimrc You could have done something more convoluted than that (ln -s foo/../.vimrc .vimrc), but in any case, as long as there isn't an actual .vimrc file, ln will create the link, but it will be a dud. ...


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.


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 ...


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' ...


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 ...


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 ...


0

The issue is SAMBA server has build in special support for unix (cifs) clients. When you use mount -t cifs on your linux host all symlinks are passed to you (cifs client) as is. ls /mnt/share/latest/dir/ -l /mnt/share/latest/dir/ -> /opt/share/data/201407 You may dislike this functionality but this is a design decision that has its pros, e.a. is not a ...


0

Hardlink creation on directories would be unrevertable. Suppose we have : /dir1 ├──this.txt ├──directory │ └──subfiles └──etc I hardlink it to /dir2. So /dir2 now also contains all these files and directories What if I change my mind? I can't just rmdir /dir2 (because it is non empty) And if I recursively deletes in /dir2... it will be deleted from ...


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

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 ...


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)


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 { ...


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.  ...



Top 50 recent answers are included