A special type of file that references a file or directory.

learn more… | top users | synonyms (1)

64
votes
5answers
17k 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 ...
29
votes
7answers
11k views

What is the difference between symbolic and hard links?

When would you use one over the other?
6
votes
5answers
1k 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 ...
3
votes
6answers
263 views

ls content of a directory ignoring symlinks

I have a directory in which I would like to list all the content (files and sub directories) without showing the symbolic links. I am using GNU utilities on Linux. The ls version is 8.13. Example: ...
15
votes
1answer
2k views

Why are reboot, shutdown and poweroff symlinks to systemctl?

In Arch Linux, if I do ls -l in /sbin, I can see that reboot, shutdown and poweroff are all symlinks to /usr/bin/systemctl. But issuing reboot, shutdown and systemctl commands obviously does not all ...
60
votes
6answers
20k 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. ...
24
votes
3answers
8k 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 ...
15
votes
1answer
26k views

Create a symbolic link relative to the current directory

I'm trying to create a symbolic link in my home directory that points to a directory on my external HDD. It works fine when I specify it like this: cd ~ ln -s /run/media/name/exhdd/Data/ Data ...
14
votes
2answers
1k 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 ...
6
votes
1answer
3k 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 ...
6
votes
4answers
3k views

Find only destination of symlink

For use in a shell-script, I'm looking for a commandline-way to get the destination of a symbolic link. The closest I've come so far is stat -N src, which outputs src -> dst. Of course I could ...
4
votes
3answers
285 views

How can I edit symlinks?

My basic understanding of a symlink is as a special file, a file that contains a string path to another file. The kernel's VFS abstracts a lot of that away but is there any reason why symlinks seem to ...
3
votes
2answers
144 views

Is there way to replace value of symbolic link? [duplicate]

Is there way to replace value of symbolic link? For example I want to replace symbolic link like this: first -> /home/username/foo/very/long/directories/that/I/do/not/want/to/type/again to ...
16
votes
4answers
10k 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?
10
votes
3answers
10k 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 ...
10
votes
4answers
5k 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 ...
23
votes
2answers
1k views

Symbolic link recursion - what makes it “reset”?

I wrote a little bash script to see what happens when I keep following a symbolic link that points to the same directory. I was expecting it to either make a very long working directory, or to crash. ...
10
votes
5answers
758 views

Is there an algorithm to decide if a symlink loops?

Unix systems usually just error out if they are confronted with a path that contains a symlink loop or just too many symlinks, because they have a limit to the number of symlinks they will traverse in ...
3
votes
3answers
2k views

Adding to path vs. linking from /bin

Our sys admin installed a software (Maven) on the server, and told everyone to add the "/usr/local/maven/bin/" folder to their path. I think it could be more convenient to just link the few programs ...
15
votes
1answer
5k views

Make cd follow symbolic links

I have my code mounted as an sshfs in my home directory, but the hierarchy is difficult to remember, so I created a symlink in my home directory leading to that directory. Is there a way so that when ...
12
votes
6answers
1k views

Portable way to get script's absolute path?

What is a portable way for a (zsh) script to determine its absolute path? On Linux I use something like mypath=$(readlink -f $0) ...but this is not portable. (E.g., readlink on darwin does not ...
7
votes
1answer
360 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 ...
2
votes
2answers
3k views

Get path of current script when executed through a symlink

I have a utility consisting of a couple directories with some bash scripts and supporting files that will be deployed to several machines possibly in a different directory on each machine. The ...
7
votes
2answers
1k 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 ...
5
votes
1answer
471 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
3answers
770 views

Linux find and remove all symlinks relating to a directory

So, I have a bit of a situation where I created many symlinks in an attempt to get them to work, trying all sorts of combinations .. now I have this error: ls: cannot access /etc/sv/me: Too many ...
4
votes
2answers
1k views

Trailing slashes on symbolic links to directories

I'm trying to emulate the process of path resolution (see man page path_resolution) in unix-like systems. My OS is Linux with GNU coreutils 8.7. In order to clarify the meaning of extra trailing '/' ...
4
votes
2answers
826 views

Why is bash completion of a symlink different than a directory?

I usually do a find with an environment variable as the path when searching for source code. Recently I replaced my environment variable with a symbolic link, and it broke Bash's shell completion. ...
4
votes
6answers
2k 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 ...
3
votes
1answer
575 views

How do you increase MAXSYMLINKS

In a python script, I am creating a bunch of symbolic links chained together. example: link1->link2->link3->.......->somefile.txt I was wondering how you can change the max number of symlinks to be ...
8
votes
2answers
2k 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, ...
7
votes
4answers
686 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 ...
4
votes
2answers
345 views

Is symlink's target relative to the destination's parent directory and if so, why?

I've got the following file structure: build/ client/ –> index.js And when I try to create a symbolic link named "client" inside the build directory that refers to the client directory in the ...
4
votes
2answers
2k views

How does /dev/fd relate to /proc/self/fd/?

$ ls -l /dev/stdin /dev/fd/0 lrwx------ 1 tim tim 64 2011-08-07 09:53 /dev/fd/0 -> /dev/pts/2 lrwxrwxrwx 1 root root 15 2011-08-06 08:14 /dev/stdin -> /proc/self/fd/0 $ ls -l /dev/pts/2 ...
4
votes
4answers
442 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?
3
votes
1answer
104 views

Test for link with trailing slash?

I created in /tmp/test/ mkdir somedir ln -s somedir/ somelink I want to loop through only directories: for file in */ ; do if [[ -d "$file" && ! -L "$file" ]]; then echo "$file is a ...
2
votes
2answers
3k views

Recursive scp without following links or creating a giant tar file?

So I did a recursive scp on my remote fileserver (in another state) and it created an infinite loop of links on my remote web directory... ...
2
votes
2answers
825 views

How do I dereference links when extracting from a tar file?

If I have a tar file, bob.tar, which contains real_file and link_to_real_file, in which the latter is a symlink, is there a way to extract the contents of bob.tar so that link_to_real_file will not be ...
2
votes
1answer
2k views

Why can't list file/directory relative to .. from a symbolic link directory (No such file or directory)?

I have a /usr/tomcat6/logs directory linked to /var/log/tomcat6. When I changed directory to /usr/tomcat6/logs and try to ls files using a relative pathname ../conf/Catalina/localhost, a No such file ...
1
vote
1answer
25 views

How to find the package that installed a comand, if “dpkg -S” finds no path because the command is a symlink?

While I was writing up a tag information for rename, I tried to look up with which package the rename command was installed. I ran the usual "dpkg -S" (also mentioned in this question): $ which ...
1
vote
2answers
951 views

Keep tracking of symbolic links?

I use symbolic links quite often, but after moving the original file, I lose track of the symbolic link. I also use symbolic links for keeping track of some files in the same directory, but again, I ...