Questions tagged [symlink]

A special type of file that references an inexistent or existing file or directory. The contents of a symbolic link consist of an arbitrary string that is the path to the file that the symbolic link points to. When the symlink is encountered during pathname resolution, the string stored by the file is used to modify the pathname resolution.

A special type of file that references an inexistent or existing file or directory. The contents of a symbolic link consist of an arbitrary string that is the path to the file that the symbolic link points to. When the symlink is encountered during pathname resolution, the string stored by the file is used to modify the pathname resolution.

The ln command with the -s flag is typically used to create symbolic links. The actual contents of the symbolic link can be examined using the readlink command.

1132 questions
410
votes
13 answers

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. I'm currently doing: find ./ -type l -exec file…
gabe.
  • 11,644
  • 11
  • 44
  • 58
311
votes
1 answer

How to change where a symlink points

Can you tell me what this is in the area marked red? If I want to change /media/files/tb-prod/files to some other path, how would I do that?
Jalil Khan
  • 3,221
  • 2
  • 12
  • 11
157
votes
3 answers

How to change ownership of symbolic links?

I am facing some issue with creating soft links. Following is the original file. $ ls -l /etc/init.d/jboss -rwxr-xr-x 1 askar admin 4972 Mar 11 2014 /etc/init.d/jboss Link creation is failing with a permission issue for the owner of the file: ln…
Zama Ques
  • 3,186
  • 12
  • 39
  • 54
155
votes
7 answers

Why are hard links to directories not allowed in UNIX/Linux?

I read in text books that Unix/Linux doesn't allow hard links to directories but does allow soft links. Is it because, when we have cycles and if we create hard links, and after some time we delete the original file, it will point to some garbage…
user3539
  • 4,288
  • 9
  • 34
  • 44
147
votes
2 answers

Create symlink - overwrite if one exists

I want to take down data in /path/to/data/folder/month/date/hour/minute/file and symlink it to /path/to/recent/file and do this automatically every time a file is created. Assuming I will not know ahead of time if /path/to/recent/file exists, how…
drjrm3
  • 1,885
  • 4
  • 16
  • 17
137
votes
10 answers

How to get scp to copy the file instead of its symlink

I want to scp a file to a server. The file is a symbolic link, and actually what I want to do is copy the source file. I don't want to track the source file's path manually, because it can be replaced. How do I get the source file's absolute path so…
Eonil
  • 4,607
  • 11
  • 30
  • 30
116
votes
4 answers

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 However it creates a faulty link when I try this: cd…
jcora
  • 3,874
  • 7
  • 34
  • 52
104
votes
7 answers

How can I edit symlinks?

My basic understanding of a symlink is that it's 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 be impossible to edit? In other words:…
Oli
  • 15,808
  • 10
  • 42
  • 51
104
votes
4 answers

What is the difference between 'rm' and 'unlink'?

Assuming you know the target is a symbolic link and not a file, is there any difference between using rm and unlink to remove the link?
IQAndreas
  • 10,145
  • 21
  • 59
  • 79
102
votes
5 answers

How do you make samba follow symlink outside the shared path

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 windows, after using internet, I cannot open S:/temp,…
mit
  • 1,413
  • 3
  • 12
  • 17
98
votes
1 answer

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 I cd to that symbolic link, instead of cding to…
rowantran
  • 1,805
  • 2
  • 13
  • 7
96
votes
2 answers

How do I copy a symbolic link?

I have a symbolic link to a file in one directory. I would like to have that same link in another directory. How do I copy a symbolic link? I tried to cp the symbolic link but this copies the file it points to instead of the symbolic link itself.
User
  • 2,197
  • 2
  • 20
  • 22
95
votes
8 answers

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 bar.txt /home/beau/bar.txt $ readlink -f…
Humphrey Bogart
  • 1,521
  • 1
  • 11
  • 7
89
votes
13 answers

Tips for remembering the order of parameters for ln?

I have used ln to write symbolic links for years but I still get the order of parameters the wrong away around. This usually has me writing: ln -s a b and then looking at the output to remind myself. I always imagine to be a -> b as I read it when…
Zhro
  • 2,495
  • 4
  • 28
  • 45
84
votes
7 answers

Determining if a file is a hard link or symbolic link?

I'm creating a shell script that would take a filename/path to a file and determine if the file is a symbolic link or a hard link. The only thing is, I don't know how to see if they are a hard link. I created 2 files, one a hard link and one a…
k-Rocker
  • 1,375
  • 2
  • 12
  • 9
1
2 3
75 76