Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [ln]

ln - Command line tool to create hard links to existing files and soft links to existing and non-existent files.

3
votes
1answer
72 views

rm to remove a dir, any symlinks, AND symlink destinations? [duplicate]

I have two directories: /all/origins/ & /all/links/. Everything in links/ points individually to something in origins/, but not everything in origins/ is linked in links/. (Squares, rectangles &...
1
vote
1answer
45 views

unlink delete files which are not links [duplicate]

I created a hard link $ ln hours.sh hours_link test it $ ls -l hours* -rw-r--r-- 2 me staff 653 Apr 12 2018 hours.sh -rw-r--r-- 2 me staff 653 Apr 12 2018 hours_link remove it with unlink $ ...
5
votes
2answers
405 views

ln: create symlink using another symlink

Let's suppose I have one file and one directory: $ ls -l total 4 drwxrwxr-x. 2 user user 4096 Oct 8 09:53 dir -rw-rw-r--. 1 user user 0 Oct 8 09:53 file I created a symlink to file called ...
1
vote
1answer
57 views

How to create a link (ln -s) with an absolute path?

So using ln -s to make a link will make either a relative link (link->../file) or an absolute link (link->/home/user/dir1/file). But sometimes I don't want to type the entire absolute path, but ...
0
votes
2answers
2k views

mkdir -p if final target is symlink

Say we have: node_modules/ suman/ and node_modules/suman is a symlink if we do: mkdir -p "$PWD/node_modules/suman" I assume mkdir -p will not overrwrite the symlink? what about if $PWD/...
0
votes
2answers
219 views

What is the meaning of 'ln -sT' in Linux?

To be more precise: I know what the -s options stands for - I use it daily. But I saw someone in a tutorial, who was moving the document root of his website from /var/www/html/project to ~/www/project ...
10
votes
3answers
2k views

Why I can't create a hard link from device file in other than /dev directory?

When I wanted to create a hard link in my /home directory in root mode, Linux showed the following error message: ln: failed to create hard link ‘my_sdb’ => ‘/dev/sda1’: Invalid cross-device link ...
1
vote
1answer
728 views

Use libgfrotran.so.3 and GFORTRAN_1.0 on fedora 27

I am trying to use fortran code called SAMMY-8 which has its binary ready for use. I was using without any issue while I had f25 installed. When upgrading to f27 I got the following error when trying ...
1
vote
1answer
153 views

Create hard link if possible, else use symlink

I am trying to write a shell script to create link for file from my dotfiles repo to my home folder. I want to use hard link if possible because it cannot be broken when moving it to somewhere in ...
1
vote
1answer
32 views

Why can't a project compile with symbol link

I'm working in a team, which develops a c++ (ROS) project. For some reason, we haven't a good git management. We have several git branches. To compile the project, I have to git clone the codes from ...
1
vote
1answer
44 views

Paths in ln with hard links and soft links

How does the relative paths work in ln (-s or not)? For example if I type ln -s foo bar/banana.txt what does this mean? What is foo relative to? Because it doesn't seem to be relative to the current ...
0
votes
2answers
39 views

How do I delete all non-link files from a folder in Linux?

I accidentally copied a bunch of junk into /usr/lib . How do I rm everything in there except folders and link files?
1
vote
1answer
354 views

Multiple symlinks by wildcard: “ln -s ../*/*.txt TXT/”

I'm trying to create multiple symbolic links using wildcard, here the example: $ ls -R .: TXT a b ./TXT: ./a: a.txt ./b: b.txt There is a "parent directoory" containing various subdirs: a, b, ...
1
vote
2answers
27 views

How can I stack wildcards to target specific files?

I want to target all files called fooxxxbarxxx. The common thing among all those files is that it contains foo and bar. I've tried to use *foo*bar* and *foo**bar* but it doesn't work. Specifically,...
2
votes
3answers
110 views

Remove symlinks originating from specific directory

I have an "install.sh" that installs my personal scripts: find /home/Steven -name '*.sh' -exec ln -s -t /usr/local/bin {} + I would like to make an "uninstall.sh" that removes the symbolic links ...
0
votes
2answers
143 views

Shell script keeps making broken symbolic links

I'm trying to manage my dot files inside a sub directory of $HOME and write a shell script that sets up symbolic links inside $HOME. #!/bin/sh for i in .cvsignore .gitconfig .npmrc .tmux.conf ....
0
votes
2answers
608 views

Rm hardlink without removing file/directory itself

Say I create a hardlink with ln x y. Is there a way to remove the link at y without removing the file at x, after I create the link? It looks like I did a rm -rf on y and it deleted x as well, would ...
-1
votes
2answers
371 views

Making a link using ln -s [duplicate]

I'm trying to make a link using: ln -s /Backup files/ /link 1 Instead of making the link, I'm get the following output: ln: target '/link' is not a directory What am I doing wrong?
2
votes
2answers
175 views

Why can a softlink to a directory be created with or without the trailing slash?

I have found that when creating a symbolic link to a folder it is produced with or without the trailing slash based on your input. for example: $ ln -sfv /ln-test/FOLDER/ test-tail test-tail -> /...
1
vote
0answers
401 views

Nested Mount Best Practice

I have two filesystems that need to be mounted on a RedHat system /apps and /apps/label. /apps will have several sub directorates and label will just have files FTP'd to it. Would it be better to ...
0
votes
1answer
82 views

Problem to install latest version of shellcheck from tar.xz

I have been downloading the latest version of ShellCheck and tried to install it on my System taking the following steps: I downloded shellcheck-latest.linux.x86_64.tar.xz then I run as root: # ...
7
votes
2answers
1k views

Why can't I create a `hardlink` to a file from a “mount --bind” directory on the same filesystem?

Original Problem I have a file on one filesystem: /data/src/file and I want to hard link it to: /home/user/proj/src/file but /home is on one disk, and /data is on another so I get an error: $ cd /...
0
votes
1answer
233 views

how do i link one directory to another directory so that FTP or SMB share can still use that directory

Needing to link a SMB share directory to a empty directory with a FTP share. There is a empty directory inside of FTP_Share1 called smbshare which I am trying to link to SMB_Share1 to access all of ...
1
vote
2answers
78 views

Why Does `'ln -s /directory 'D:'` Work Like It Does?

So, as mentioned here, 'ln -s /directory 'D:' maps the windows D: location to a Linux style directory. However, as far as I know, this goes against the Linux naming system. Why does Linux allow the ...
1
vote
1answer
50 views

ln -s reports that a procedure failed, but creates symlinks nonetheless

I have a really stupid question that bugs me a lot. I am in the parent directory and there are a number of files with .fastq, .fq, .fastq.gz and .fq.gz extensions in different subdirectories. I ...
2
votes
1answer
77 views

Inconsistent behaviour creating symbolic links with relative and force flag

I have an issue with creating symbolic links with ln, with the relative and the force flag set. The scenario is as follows: $ tree . ├── folder1 │   └── file └── folder2 I create the link: $ ln -...
5
votes
2answers
2k views

Size of symlink

Symbolic links do take room, of course, but just the room it takes to store the name and target plus a few bytes for other metadata Do symbolic links actually make a difference in disk usage? My ...
4
votes
1answer
4k views

How to force creation of a symbolic link?

I have a particular directory full of other directories organized (named) by date. For ease of reference, I have a symlink called current pointing to the latest one. In the script that creates new ...
1
vote
2answers
221 views

Symbolic link directories redirects to itself

I created a symbolic link to OneDrive using the following ln -s ~/in_between_directories/OneDrive/ ./onedrive When I cd into onedrive from my working directory it correctly displays the directories ...
1
vote
1answer
253 views

create symlink with ln but a loop will be created

I would like to create a symlink from my source: /nfs/www/example.com/sourcefolder to this destination: /var/www/example.com/destinationfolder So I run this command: ln -s /nfs/www/example.com/...
2
votes
2answers
329 views

Best workaround for file's symbolic link with different group tham file

Target situation: data/file.txt owned by myUser:myUser and "-rw-rw-rw-" (chmod 666) symbolic link /tmp/file.txt owned by postgres:postgres and "-rw-rw-rw-" So, I can edit the file with my user, and ...
4
votes
1answer
166 views

Keeping dotfiles in sync for different folders

I am using Dropbox for storing my dotfiles from which I create soft links to my home directory. For configuration files which I do edit by myself it works very good, however applications like firefox ...
3
votes
2answers
563 views

Symbolic link with option

Is it possible to create a symbolic link to an executable that executes it with a certain option/argument? I know a workaround would be to create a bash script in one of the PATH directories but can ...
0
votes
1answer
103 views

Is existing file removed when a symlink is created with the same name?

So there was a file dummy1. I created a symlink: ln -snf dummy dummy1 and confused source and target file, as I actually wanted dummy to point to dummy1 not vice versa. So now dummy1 is a symlink. ...
0
votes
1answer
53 views

'ln' doesn't behave the same when executed in a script [closed]

I'm trying to install Guacamole through a script. When it comes to link the files stored in /etc/guacamole to tomcat8 directory, the following line works well when executed in the shell : ln -s /etc/...
1
vote
0answers
65 views

Why root lose permission of 1st and 2nd level symlink? [duplicate]

Why root lose permission to run 1st level symlink /bin/planet and 2nd level symlink /tmp/earth, except symlink target /tmp/sun at the end ? Instead ordinary user no problem to run 3 of them: xiaobai@...
2
votes
1answer
114 views

Is it possible to create such a soft link?

I created a soft link with following command: ln -s "/media/Eric/node/language/1-1.English/space@English/7-2 IELTS" ~/desktop/IELTS On my desktop, when click to open the IELTS dir, the path is /home/...
1
vote
1answer
169 views

advantages of hard-link of file over copy of the file

I have a Bourne shell script which accepts single argument(text-file usually few KB in size). Essentially this script is a wrapper for scp which copies this text-file to remote server. Script does not ...
3
votes
2answers
455 views

cp overwriting without overwriting hardlinks to destination

Say I have the following setup : $ cat fileA textA $ cat fileB textB $ ln fileA myLink $ cat myLink # as expected textA I do not understand the following behaviour : $ cp fileB fileA $ cat myLink #...
4
votes
2answers
2k views

What is the difference between the link and ln commands?

From the man pages: ln - make links between files and link - call the link function to create a link to a file These seem to do the same thing however ln takes a lot of options as well. Is link ...
1
vote
1answer
338 views

Why ln -s copied a file instead of linking it?

Please see the screenshot. For two times I have run ln -s and it creates a copy of a small text file instead of linking it. The exact command I have run is: lobianco@lobianco-officeLaptopLatitude:~/...
-3
votes
1answer
215 views

Does this example implement the same as `ln -sr`?

From coreutils' manual about ln -r --relative Make symbolic links relative to the link location. Example: ln -srv /a/file /tmp ’/tmp/file’ -> ’../a/file’ Relative symbolic ...
1
vote
4answers
1k views

Why change the current directory to the parent directory of a relative symlink before creating it

From the manual of coreutils, for ln When creating a relative symlink in a different location than the current directory, the resolution of the symlink will be different than the resolution of ...
4
votes
2answers
4k views

Does `ln -sf` overwrite existing files which are only symbolic links

From the coreutils ln manual: Normally ln does not remove existing files. Use the --force (-f) option to remove them unconditionally, the --interactive (-i) option to remove them conditionally, ...
2
votes
2answers
3k views

Understanding the usage of ln

From coreutils' manual, for ln ln makes links between files. By default, it makes hard links; with the -s option, it makes symbolic (or soft) links. Synopses: ln [option]... [-T] target linkname ...
2
votes
2answers
213 views

check if there is a link from the current file

How can I check if there is a link from the current file on Linux? Say, I have: touch foo ln -s foo bar ll foo bar bar -> foo foo Now, I want to know, if there are any file linked from foo:e.g. ...
3
votes
1answer
772 views

How to Relink these symlinks after moving the system?

I moved my filesystem and symlinks from Ubuntu 14.04 to 16.04 by using FAT32 memory card, which apparently broke those links; stopped using BitTorrentSync. Differential condition is that those links ...
1
vote
1answer
1k views

Can I replace a directory with a symlink without write permissions in parent?

I would like to replace a directory with a symlink. For the directory itself I have full permissions (rwx), but for the parent directory I don't have write permissions (r-x). Is this possible? The ...
2
votes
2answers
386 views

Is there a way to not create a sym link if the folder exists

I have something like folder A and when I do ln -s A a it creates the sym linked folder a now if I repeat the command ln -s A a I get the dead link a/A Is there a way that I can have ln fail if ...
1
vote
2answers
68 views

How are hard links counted in UNIX? [duplicate]

When we create a directory in UNIX it has 2 hard links: . and ... One to itself and another one to its parent directory. As I read the . increases counter of the directory, and the .. increases hard ...