Questions tagged [symlink]

Symlink is short for symbolic link (also soft link). It is a term for any file that contains a reference to another file or directory in the form of an absolute or relative path and that affects pathname resolution.

symlink is short for symbolic link (also soft link). It is a term for any file that contains a reference to another file or directory in the form of an absolute or relative path and that affects pathname resolution

2458 questions
2192
votes
18 answers

How can I symlink a file in Linux?

I want to make a symbolic link in Linux. I have written this Bash command where the first path is the folder I want link into and the second path is the compiled source. ln -s '+basebuild+'/IpDome-kernel/kernel…
chrisg
  • 40,337
  • 38
  • 86
  • 107
2028
votes
4 answers

How does Git handle symbolic links?

If I have a file or directory that is a symbolic link and I commit it to a Git repository, what happens to it? I would assume that it leaves it as a symbolic link until the file is deleted and then if you pull the file back from an old version it…
Alex
  • 34,776
  • 10
  • 53
  • 68
1191
votes
12 answers

Remove a symlink to a directory

I have a symlink to an important directory. I want to get rid of that symlink, while keeping the directory behind it. I tried rm and get back rm: cannot remove 'foo'. I tried rmdir and got back rmdir: failed to remove 'foo': Directory not empty I…
Matthew Scouten
  • 15,303
  • 9
  • 33
  • 50
1046
votes
23 answers

What is the difference between a symbolic link and a hard link?

Recently I was asked this during a job interview. I was honest and said I knew how a symbolic link behaves and how to create one, but do not understand the use of a hard link and how it differs from a symbolic one.
Nick Stinemates
  • 41,511
  • 21
  • 59
  • 60
384
votes
8 answers

How do I find all of the symlinks in a directory tree?

I'm trying to find all of the symlinks within a directory tree for my website. I know that I can use find to do this but I can't figure out how to recursively check the directories. I've tried this command: find /var/www/ -type l … and later I…
hafichuk
  • 10,351
  • 10
  • 38
  • 53
340
votes
16 answers

Git symbolic links in Windows

Our developers use a mix of Windows and Unix-based OSes. Therefore, symbolic links created on Unix machines become a problem for Windows developers. In Windows (MSysGit), the symbolic link is converted to a text file with a path to the file it…
Ken Hirakawa
  • 7,831
  • 10
  • 38
  • 49
324
votes
11 answers

Creating hard and soft links using PowerShell

Can PowerShell 1.0 create hard and soft links analogous to the Unix variety? If this isn't built in, can someone point me to a site that has a ps1 script that mimics this? This is a necessary function of any good shell, IMHO. :)
Mike T
  • 3,696
  • 4
  • 21
  • 21
287
votes
8 answers

How to check if a symlink exists

I'm trying to check if a symlink exists in bash. Here's what I've tried. mda=/usr/mda if [ ! -L $mda ]; then echo "=> File doesn't exist" fi mda='/usr/mda' if [ ! -L $mda ]; then echo "=> File doesn't exist" fi However, that doesn't work. If…
bear
  • 11,364
  • 26
  • 77
  • 129
268
votes
14 answers

How can I get Git to follow symlinks?

Is my best be going to be a shell script which replaces symlinks with copies, or is there another way of telling Git to follow symlinks? PS: I know it's not very secure, but I only want to do it in a few specific cases.
Matt
  • 5,522
  • 5
  • 29
  • 24
258
votes
21 answers

How to resolve symbolic links in a shell script

Given an absolute or relative path (in a Unix-like system), I would like to determine the full path of the target after resolving any intermediate symlinks. Bonus points for also resolving ~username notation at the same time. If the target is a…
Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285
253
votes
3 answers

Create a symbolic link of directory in Ubuntu

Below is my code for creating a symlink of a directory: sudo ln -s /usr/local/nginx/conf/ /etc/nginx I already created the directory /etc/nginx. I just want the contents of the source directory (/usr/local/nginx/conf/) to be in the contents of the…
user959129
206
votes
10 answers

How to see full absolute path of a symlink

When I'm using ls -la symlinkName or stat symlinkName not all the path is displayed (e.g ../../../one/two/file.txt) What is the linux command that reveals the full path?
15412s
  • 3,298
  • 5
  • 28
  • 38
186
votes
6 answers

What is the difference between NTFS Junction Points and Symbolic Links?

At a high level, the only obvious difference between NTFS Junction Points and Symbolic Links is that Junctions are only able to be directories, while SymLinks are allowed to also target files. What other differences between the two exist? (Note,…
Billy ONeal
  • 104,103
  • 58
  • 317
  • 552
184
votes
5 answers

Cannot create a symlink inside of /usr/bin even as sudo

When I try to symlink a binary in my /usr/bin folder, I get an Operation not permitted error: sudo ln -s /usr/bin/python2.7 /usr/bin/python2 ln: /usr/bin/python2: Operation not permitted Even as sudo, I get this error.
egidra
  • 8,537
  • 19
  • 62
  • 89
153
votes
14 answers

Docker follow symlink outside context

Yet another Docker symlink question. I have a bunch of files that I want to copy over to all my Docker builds. My dir structure is: parent_dir - common_files - file.txt - dir1 - Dockerfile - symlink ->…
Ravi
  • 3,719
  • 6
  • 28
  • 40
1
2 3
99 100