A special type of file that references a file or directory.
29
votes
2answers
7k views
Why hard links not allowed to directories in UNIX/Linux
I read in text books that UNIX/Linux doesn't allows hard links to directories but soft links do. Is it because, when we have cycles and if we create hardlinks, and after some time we delete the ...
26
votes
6answers
4k views
How can I find broken symlinks
Is there a way to find all symbolic links that don't point anywere?
find ./ -type l
will give me all symbolic links, but makes no distinction between links that go somewhere and links that don't. ...
25
votes
7answers
4k views
20
votes
3answers
3k views
How can I “relink” a lot of broken symlinks?
I have a directory tree which has a bunch of symbolic links to files under /home... however, I have moved /home to /mnt/home and need a way to "relink" all of the symlinks. Does such functionality ...
12
votes
2answers
4k views
Do symbolic links actually make a difference in disk usage?
I've read in so many websites that, in Linux, symbolic links (soft links, symlinks) are just like pointers that reference another file, which may be located anywhere (like Windows shortcuts). However, ...
11
votes
4answers
3k views
Converting relative path to absolute path
Is there a *nix command to get absolute(and canonicalized) path from relative path(with current path) or symbolic link?
9
votes
4answers
2k views
symbolic link to a directory and relative path
I've created symlink with absolute path to the directory (Blink) and have for example following tree:
$ ls -l /tmp/A
total 0
lrwxrwxrwx 1 root root 6 Apr 3 12:27 Blink -> /tmp/B
-rw-r--r-- 1 root ...
9
votes
2answers
593 views
pwd without symlinks
If I do pwd I notice it uses whatever symlinks I used to get into the current directory. Can I get it to tell me the "real" directory I'm in ... i.e. the path from the root to my current directory ...
9
votes
1answer
116 views
Strategies for maintaining a reference to a file after it was moved or renamed?
I've had a mac at work lately, and was amazed to see that Xcode would still find my latest project after I renamed its folder and moved it someplace else.
Now I understand that this is the result of ...
9
votes
4answers
425 views
Include / in symlink to a directory?
Symlinking to a directory gives to different results with ls -l depending on whether I ln -s dir or ln -s dir/. But what's the actual difference, and which one should I prefer why?
8
votes
3answers
2k views
How can I remove all symbolic links with a special target?
With the command:
ls -la *
I can list all my symbolic links.
How can I remove all symbolic links which are linked to a special folder?
For example:
In my directory usr/local/bin I have the ...
8
votes
3answers
274 views
Symlink to part of the file?
Is there possible to create file that is just a sub-sequence of bytes from another file, like a symlink, but referencing only part of the file?
8
votes
2answers
315 views
find usage with -L
I have
link -> file
I do
find -L . -name 'link'
And get
./link
Why is that?
man find says:
-L : Follow symbolic links. When find examines or prints information about files, ...
8
votes
2answers
673 views
mv a file without breaking a symlink to that file
Is it possible to mv a file w/out breaking a symbolic link to that file?
My initial response to this is no, and I'm working out a script based solution to change the links immediately following the ...
7
votes
4answers
301 views
Linking /proc/mnt to /proc/mounts
I understand that /proc filesystem reflects the output of various processes. Unfortunately, I have a propietary (romdump) binary that expects the mount table to appear as /proc/mtd, while my Android ...
7
votes
3answers
1k views
How does one atomically change a symlink to a directory in busybox?
I am trying to (as close as possibly) atomically change a symlink. I've tried:
ln -sf other_dir existing_symlink
That just put the new symlink in the directory that existing_symlink pointed to.
ln ...
7
votes
2answers
145 views
Git do not overwrite symlinked directory on branch checkout
How can I make directory read-only with git?
The situation is - in project, I have a symlink to shared framework. I don't want it to be overwritten/changed in any way (not even mtime or atime).
How ...
6
votes
3answers
609 views
How to make a symbolic link to /usr/bin/vim but with start-up parameters?
After I make&make install vim from source, I found many symbolic links of vim in /usr/local/bin, such as evim, rvim, view...
The vim(1) man page said that "rvim" is equivalent to "vim -Z" and so ...
6
votes
2answers
779 views
Providing /bin and /lib inside a chroot jail
I need to be able to provide the /bin and /lib directories inside a chroot jail so that programs can dynamically link properly.
Is there a way to accomplish this without making a copy of the /bin and ...
6
votes
1answer
344 views
Why do some symbolic links affect program behavior?
One thing that has been puzzling me for some time is this:
% which halt
/sbin/halt
% file /sbin/halt
/sbin/halt: symbolic link to `reboot'
However, executing sudo halt does, of course, not reboot ...
6
votes
2answers
711 views
Is a symbolic/soft link similar to a shortcut/alias on a desktop?
It sounds to me like the basic idea of soft/symbolic links compared to shortcuts (on a PC) or aliases (on a Mac) are the same thing. Am I way off? Are they similar?
6
votes
2answers
2k views
Why change the owner of a symbolic link in linux?
In linux it's possible to change the owner or the group owner of a symbolic link (symlink). I was wondering why someone would want to do that, since permissions of a symlink are not used when ...
6
votes
1answer
246 views
Is there a way to make perl -i not clobber symlinks?
A friend of mine points out that if you do:
perl -pi.bak -e 's/foo/bar/' somefile
when "somefile" is actually a symlink, perl does just what the docs say it will do:
It does this by renaming ...
6
votes
5answers
673 views
Dynamic Symlinks
I have built my app for different architectures and would like to create a "dynamic symlink" which takes me to the right version based on a variable.
If the machine I am currently logged in to, is ...
6
votes
4answers
1k views
Is there a standard symbolic link to the current users home directory?
The shell can expand ~ to your home directory. $HOME usually has the same deal, but often you want to refer to the current users home directory from a context that may not support such expansion.
I ...
5
votes
1answer
123 views
Can non-canonicalized forms of filesystem paths be significant? (eg. “foo//bar”, “foo/./bar”, and “foo/../bar”)
I have a script for building a particular flavor of GCC cross-compiler. Throughout the script there are many paths that are not in canonical form, such as duplicate path separators (/xxx/foo//bar/yyy) ...
5
votes
1answer
3k views
Copy symlink AND where it points to using rsync
It doesn't need to be done by rsync, but it would be nice not have to write a script to do this, and rsync is very close to what I want.
"rsync -a" (or -l) can preserve symlinks, and -L can ...
5
votes
2answers
221 views
Find files that were not installed by the package manager
I'd like to get a list of all files in my Gentoo Linux system that were not installed by the package manager (Portage). This is because I want to keep my system as clean as possible, removing all ...
4
votes
4answers
370 views
Symbolic link and hard link questions
Let's say /A/B/c.sh is symbolic linked to /X/Y/c.sh.
If c.sh has the command "./SOMETHING", '.' means /A/B/ or /X/Y/?
How about the hard link?
4
votes
4answers
840 views
Is chmod behavior wrong for symlinks?
Recently we had a problem on a Red Hat Linux box with many users: the /usr/bin/sudo binary has lost its sticky bit. Work was blocked until root user fix it (we need sudo for deploying and testing).
...
4
votes
2answers
3k views
Are there any drawbacks from using mount --bind as a substitute for symbolic links?
Symlinks have limitations in how functions like ls, mv, and cp can operate on them because unlike shell initiated commands like cd, these functions do not have information about how the user accessed ...
4
votes
3answers
136 views
Create symbolic links to files using wildcards
I want to create symlinks to multiple files:
ln -s dev-*.php 's/dev-(.*\.php)/$1/'
Results hoped for:
site.php links to dev-site.php
file.php links to dev-file.php
What's the most ...
4
votes
4answers
3k views
List symlinks in current directory?
This question talks about finding directories in a current diretory. The solution is basically:
ls -d */
That's great but how can I easily list symlinks? Do I have to use something like
find . ...
4
votes
3answers
7k views
How to get full path of original file of a soft symbolic link?
I want to scp a file to a server. The file is a symbolic link, and actually I want to do is copying the source file. Anyway I don't want to track source file's path manually, because it can be ...
4
votes
1answer
980 views
Symbolic link permissions
I have access to a remote Linux machine where everytime I create a symbolic link, it is created by default with the following permissions: lrwxrwxrwx
If I try to change the permissions of the ...
4
votes
3answers
3k views
Make a symbolic link to a relative pathname
I can do this:
$ pwd
/home/beau
$ ln -s /home/beau/foo/bar.txt /home/beau/bar.txt
$ readlink -f bar.txt
/home/beau/foo/bar.txt
But I'd like to be able to do this:
$ pwd
/home/beau
$ cd foo
$ ln -s ...
4
votes
1answer
360 views
How can I access a directory outside a chroot from within it?
I have a user which is chrooted to her home directory, but I want her to also be able to manage files within /var/www. As such, I did the following:
root@server:/home/username# ln -s /var/www www
...
4
votes
1answer
626 views
list files by symlink target
How do I get list of files (and then do something with that list) by filtering through the symbolic link target name, and not the symlink name? For example from the following list I'm only interested ...
4
votes
2answers
88 views
Quicker Way to Reference a Directory?
This one is probably easy for all of you, but I have never had to deal with such a nested local set of directories.
If I have a path like: /mnt/media2/Archived\ Files/_Transfer/ is there a way to ...
4
votes
2answers
105 views
How to ls using the long format (-l) while still following directory symlinks?
I've noticed that ls -l doesn't only change the formatting of the output, but also how directory symlinks are handled:
> ls /rmn
biweekly.sh daily.sh logs ...
> ls -l /rmn
lrwxrwxrwx 1 root ...
4
votes
1answer
201 views
Symbolic links with ls, mv: forcing the functions to utilize “logical” addresses (remembering the original path)
It seems that for many basic functions operating on symbolic links, the physical path is used by default. However, cd works fine. When moving into a symbolic link, cd remembers where I came from so it ...
4
votes
1answer
261 views
How to replace a symbolic link with an equivalent hard link?
Having a (single, no batch filesystem processing needed) symlink, what a command line to use to turn it into a hard link to the same file?
4
votes
1answer
54 views
Can I create a symlink that will ignore subdirectories?
I'm trying to get dropbox symlinked to the relevant folders in /home. I'd like to symlink them like this:
~/Dropbox/Pictures --> ~/Pictures
~/Dropbox/Camera Uploads --> ~/Pictures/Camera ...
4
votes
1answer
81 views
How do I cd up and down again with symlinks in bash?
Structure:
/base/
+- somedir/
+- symlink/ -> /some_other_dir
This command (in addition to my Makefiles) fails:
cd /base/symlink
ls ../somedir
Bash complains that ../somedir does not ...
4
votes
2answers
523 views
What causes ln: //: Is a directory?
When linking a directory to root, I get this error:
$ ln -s ~/inbox/ /
$ ln: //: Is a directory
Bash autocompletes the directory path by adding a /. I've tried escaping without success.
$ ln -s ...
4
votes
2answers
980 views
How does linux work with symbolic links?
I mean what's going on when some process wants to read a symlink? What's going on when something changes a symlink during a read or even write process?
For example: I have 2 huge, similar 100G files ...
4
votes
2answers
273 views
How to rsync a chroot without breaking symlinks?
I'd like to rsync (backup) a chroot environment from outside the chroot.
For that I first make a lvm snapshot of the chroot volume and then run rsync on that.
The only problem with this approach: ...
4
votes
1answer
4k views
Make samba follow symlink outside share
This is ubuntu server 10.04 64 and samba 3.4.7
I have a shared directory /home/mit/share and another one /home/temp that I link into the shared one:
ln -s /home/temp /home/mit/share/temp
But on ...
4
votes
1answer
110 views
Move a file and re-target all of its symlinks [duplicate]
Possible Duplicate:
How can I “relink” a lot of broken symlinks?
Is there any way to move a file to a new location, and then re-target its symlinks to the new location, using a shell ...
3
votes
6answers
815 views
Is it possible to “roll” a symlink to a new file without affecting any open file handles?
An application I am developing locally logs it's output to files formatted with the current timestamp such as app-%Y%m%d.log.
To make it simple to be able to tail the current's day log in a terminal ...
