Skip to main content

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.

Filter by
Sorted by
Tagged with
2233 votes
18 answers
2.3m views

How can I symlink a file in Linux? [closed]

I want to create a symbolic link in Linux. I have written this Bash command where the first path is the folder I want to link, and the second path is the compiled source. ln -s '+basebuild+'/IpDome-...
chrisg's user avatar
  • 41.2k
2107 votes
4 answers
681k views

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 ...
Alex's user avatar
  • 35.9k
1196 votes
10 answers
1.0m views

Remove a symlink to a directory [closed]

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: ...
Matthew Scouten's user avatar
1125 votes
23 answers
542k views

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 ...
Nick Stinemates's user avatar
399 votes
8 answers
505k views

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 ...
hafichuk's user avatar
  • 10.7k
364 votes
19 answers
192k views

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 ...
Ken Hirakawa's user avatar
  • 8,131
338 votes
11 answers
305k views

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 ...
Mike T's user avatar
  • 3,846
299 votes
8 answers
438k views

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 "=> ...
bear's user avatar
  • 11.5k
276 votes
14 answers
127k views

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 ...
Matt's user avatar
  • 5,612
268 votes
21 answers
226k views

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 ...
Greg Hewgill's user avatar
254 votes
3 answers
472k views

Create a symbolic link of directory in Ubuntu [closed]

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 (/...
user avatar
231 votes
10 answers
374k views

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's user avatar
  • 3,598
200 votes
6 answers
125k views

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 ...
Billy ONeal's user avatar
193 votes
5 answers
172k views

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

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 ...
egidra's user avatar
  • 8,907
171 votes
16 answers
148k views

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 ...
Ravi's user avatar
  • 3,899
148 votes
4 answers
173k views

How do I symlink all files from one directory to another in bash? [closed]

I want to link ( ln -s ) all files that are in /mnt/usr/lib/ into /usr/lib/ There are lots of files, how can it be done quickly? :)
user avatar
145 votes
8 answers
174k views

Can you change what a symlink points to after it is created?

Does any operating system provide a mechanism (system call — not command line program) to change the pathname referenced by a symbolic link (symlink) — other than by unlinking the old one and creating ...
Jonathan Leffler's user avatar
144 votes
3 answers
105k views

symbolic link: find all files that link to this file

Hallo all, I need to do this in linux: Given: file name 'foo.txt' Find: all files that are symbolic links to 'foo.txt' How to do it? Thanks!
lukmac's user avatar
  • 4,761
127 votes
8 answers
61k views

Can sphinx link to documents that are not located in directories below the root document?

I am using Sphinx to document a non-Python project. I want to distribute ./doc folders in each submodule, containing submodule_name.rst files to document that module. I then want to suck those files ...
mc_electron's user avatar
  • 1,522
120 votes
7 answers
146k views

How do I remove a symlink?

I just created the symbolic link sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib and am wondering: how can I get rid of it if I wanted to? How would I do this?
locoboy's user avatar
  • 38.6k
115 votes
5 answers
281k views

Nginx sites-enabled, sites-available: Cannot create soft-link between config files in Ubuntu 12.04

I am trying to create soft links between config files containing server blocks in the sites-enabled and sites-available directories in /etc/nginx/. The command I am using is: sudo ln -s sites-...
iamyojimbo's user avatar
  • 4,561
106 votes
14 answers
165k views

Apache won't follow symlinks (403 Forbidden)

I'm having some trouble setting up Apache on Ubuntu. I've been following this guide. # /usr/sbin/apache2 -v Server version: Apache/2.2.17 (Ubuntu) Server built: Feb 22 2011 18:33:02 My public ...
Tim's user avatar
  • 6,159
103 votes
6 answers
94k views

How to find files excluding symbolic links?

I want to find files in Linux that follow a certain pattern but I am not interested in symbolic links. There doesn't seem to be an option to the find command for that. How shall I do ?
Barth's user avatar
  • 15.5k
102 votes
3 answers
79k views

Does Amazon S3 support symlinks?

I have an object which I would like to address using different keys without actually copying the object itself, like a symlink in Linux. Does Amazon S3 provide such a thing?
The user with no hat's user avatar
96 votes
3 answers
21k views

How do I change my pwd to the real path of a symlinked directory?

Here's a rather elementary *nix question: Given the following symlink creation: ln -s /usr/local/projects/myproject/ myproject ... from my home directory /home/jvf/, entering the myproject symlink ...
Johan Fredrik Varen's user avatar
88 votes
3 answers
70k views

How to check if a directory/file/symlink exists with one command in Ruby

Is there a single way of detecting if a directory/file/symlink/etc. entity (more generalized) exists? I need a single function because I need to check an array of paths that could be directories, ...
claudiut's user avatar
  • 1,693
87 votes
10 answers
113k views

Is there a way to edit a symbolic link without deleting it first? [duplicate]

So I created a symbolic link: ln -s /location/to/link linkname Now I want to change the location that the symlink links to. How do I do that? Is there a way to do it without deleting it first?
Andrew's user avatar
  • 235k
85 votes
6 answers
86k views

how to find the target file's full(absolute path) of the symbolic link or soft link in python

when i give ls -l /etc/fonts/conf.d/70-yes-bitmaps.conf lrwxrwxrwx <snip> /etc/fonts/conf.d/70-yes-bitmaps.conf -> ../conf.avail/70-yes-bitmaps.conf so for a symbolic link or soft link, ...
duhhunjonn's user avatar
  • 45.3k
84 votes
9 answers
65k views

Delete all broken symbolic links with a line?

For a given folder, how can I delete all broken links within it? I found this answer that shows how to delete one broken link, but I can't put that together in only one line. Is there a one-liner for ...
fotanus's user avatar
  • 19.9k
82 votes
8 answers
80k views

Telling git to ignore symlinks

This question has appeared in similar forms here and here, but they don't seem to match up with what I'm looking for. I'm making a project in StaticMatic, a Ruby static site generator. Basically, it'...
user225643's user avatar
  • 3,661
76 votes
16 answers
63k views

How to convert symlink to regular file?

What is the most direct way to convert a symlink into a regular file (i.e. a copy of the symlink target)? Suppose filename is a symlink to target. The obvious procedure to turn it into a copy is: ...
nibot's user avatar
  • 14.8k
76 votes
9 answers
76k views

Is there a way to check if there are symbolic links pointing to a directory?

I have a folder on my server to which I had a number of symbolic links pointing. I've since created a new folder and I want to change all those symbolic links to point to the new folder. I'd ...
nickf's user avatar
  • 543k
76 votes
5 answers
54k views

is there a way to see the actual contents of a symlink?

When you do cat some-symlink-to-some-real-file it shows the contents of the real file, not what is within the symlink itself. Is there a way to see what's actually in it?
fabio's user avatar
  • 2,329
75 votes
4 answers
114k views

Docker and symlinks

I've got a repo set up like this: /config config.json /worker-a Dockerfile <symlink to config.json> /code /worker-b Dockerfile <symlink to config.json> /code However,...
Chris B.'s user avatar
  • 88.6k
68 votes
3 answers
49k views

What happens when I clone a repository with symlinks on Windows?

There's been a lot of questions about adding support for symlinks on Windows. But, what actually happens when I clone a repository with symlinks on Windows?
Andres Riofrio's user avatar
66 votes
7 answers
66k views

Linux: Find all symlinks of a given 'original' file? (reverse 'readlink')

Consider the following command line snippet: $ cd /tmp/ $ mkdir dirA $ mkdir dirB $ echo "the contents of the 'original' file" > orig.file $ ls -la orig.file -rw-r--r-- 1 $USER $USER 36 ...
sdaau's user avatar
  • 38.1k
65 votes
8 answers
46k views

How can I detect whether a symlink is broken in Bash?

I run find and iterate through the results with [ \( -L $F \) ] to collect certain symbolic links. I am wondering if there is an easy way to determine if the link is broken (points to a non-...
zoltanctoth's user avatar
  • 2,867
60 votes
8 answers
105k views

How do I overcome the "The symbolic link cannot be followed because its type is disabled." error when getting the target of a symbolic link?

Following on from a previous question, I am creating a symbolic link on a Server 2008 from a Vista machine using UNC paths. I can create the link just fine. I can go to the Server 2008 box and double ...
David Arno's user avatar
60 votes
5 answers
55k views

How to get symlink target in Python?

Using Python, I need to check whether hundreds of symlinks are correct and recreate them when not. What I do now is to compare real paths of what I want and what I have, but it's slow because it's ...
zorggy's user avatar
  • 601
60 votes
3 answers
73k views

`os.symlink` vs `ln -s`

I need to create a symlink for every item of dir1 (file or directory) inside dir2. dir2 already exists and is not a symlink. In Bash I can easily achieve this by: ln -s /home/guest/dir1/* /home/guest/...
jurgenreza's user avatar
  • 5,996
60 votes
2 answers
37k views

In Bash, how do I safely determine what a soft link points to?

I need to process a number of directories, determine what files in them are symlinks, and what they link to. This sounds simple, but I have no control over the presence of control or other characters ...
swestrup's user avatar
  • 4,167
59 votes
5 answers
53k views

Symlink broken right after creation

I downloaded the linux Tor Browser package, which is a self-contained folder. I made a symlink to the run script: $ ln -s torbrowser/start-tor-browser ~/bin/torbrowser However, the link was broken ...
joshlf's user avatar
  • 23k
57 votes
5 answers
22k views

Enable native NTFS symbolic links for Cygwin

Recent NTFS and Windows implement symlinks: NTFS junction point can be used as directory symlink since NTFS 3.0 (Windows 2000) using linkd or junction tools. NTFS symbolic link can also be used as ...
oHo's user avatar
  • 53.5k
57 votes
3 answers
34k views

Does creating a symbolic link to another symbolic link have any side-effects?

Does creating a symlink to another symlink on a linux box have any side effects (specifically in terms of performance)?
5gfbtest's user avatar
  • 571
53 votes
3 answers
22k views

How do I get the target of a symlink?

I have a string containing the file system path to an existing symlink. I want to get the path that this link points to. Basically I want the same that I'd get through this bit of hackery: s = "path/...
kch's user avatar
  • 78.9k
53 votes
8 answers
52k views

Modifying a symlink in python

How do I change a symlink to point from one file to another in Python? The os.symlink function only seems to work to create new symlinks.
meteoritepanama's user avatar
49 votes
9 answers
52k views

Find out whether a file is a symbolic link in PowerShell

I am having a PowerShell script which is walking a directory tree, and sometimes I have auxiliary files hardlinked there which should not be processed. Is there an easy way of finding out whether a ...
Joey's user avatar
  • 351k
48 votes
3 answers
116k views

Nginx not following symlinks

I have installed nginx on Ubuntu 12.04. However, nginx does not seem to follow symlinks. I understand that there is a config change required for this but I am not able to find where to make the change....
Neo's user avatar
  • 3,605
48 votes
2 answers
37k views

How can I derefence symbolic links in bash? [duplicate]

How can I take any given path in bash and convert it to it's canonical form, dereferencing any symbolic links that may be contained within the path? For example: ~$ mkdir /tmp/symtest ~$ cd /tmp/...
David Dean's user avatar
  • 7,611
47 votes
9 answers
37k views

Check if a file is real or a symbolic link

Is there a way to tell using C# if a file is real or a symbolic link? I've dug through the MSDN W32 docs, and can't find anything for checking this. I'm using CreateSymbolicLink from here, and it's ...
mattdwen's user avatar
  • 5,378

1
2 3 4 5
50