Questions tagged [ln]

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

Filter by
Sorted by
Tagged with
-2 votes
1 answer
63 views

What are the implications of adding "./" to relative symbolic links?

I noticed that when I create relative symbolic links, starting the source path with ./ keeps it that way and starting with an alphanumeric character keeps it that way, despite them both meaning the ...
user avatar
  • 231
0 votes
1 answer
79 views

Command substitution with xargs inputs [duplicate]

I'm trying to write a simple command that will create symlinks for all files in a specific directory (Yes, exactly like lndir but I cannot use it so I try to mimic it). I tried the following using ...
user avatar
0 votes
1 answer
53 views

How can I make a program I've added to the PATH run from the terminal?

I've followed this question to add eclipse to the path (using ln -s to make a link to /usr/local/bin/eclipse from home download), and when i type whereis eclipse I get /usr/local/bin/eclipse, but when ...
user avatar
  • 11
1 vote
1 answer
56 views

ln: create relative symlink to a relative symlink

I want to create a relative symlink pointing to a relative symlink, not to the relative symlink's target. It seems that when creating a relative symlink ln resolves TARGET instead of pointing to the ...
user avatar
  • 507
2 votes
0 answers
31 views

Maintain Ownership While Updating Symbolic Links

I'm migrating a file system and I need to update a few thousand symbolic links that'll break as a result of the migration. My plan was to find all the affected links and build a script that'd process ...
user avatar
  • 63
0 votes
0 answers
53 views

Suggestions for issues with symbolic links

I love symbolic links. They allow me to reference a file from multiple places in my file system, use convenient names to refer to files with complex file names in a transparent manner (rather than ...
user avatar
1 vote
1 answer
183 views

Is symbolic link to hardlink (inode) of directory possible? (that would point to the same physical location after mount on top of that directory?)

Some time ago I wanted to be able to access files in a directory which was overshadowed by later mount point. I recall finding several QAs on SE giving answers, but I recall none I've tried worked. ...
user avatar
0 votes
1 answer
66 views

Hard link to soft link

Can one force ln not to follow a soft link in its first argument? For example, in the following I would like hard to be a hard link to the soft link soft: $ mkdir dir $ ln -s dir soft $ ln soft hard ...
user avatar
  • 3
0 votes
1 answer
295 views

On xfs, why can't I hardlink to /tmp/, giving the error "Invalid cross-device link" when my fstab indicates tmp is on the same partition?

My error: ln "99700.fa821246f01ef7f3d86a503e33de5753b50640d69de790fd3db5a5dc31ffa45d1dc64a93f950379ee432aa27cbb0593e6e50ddbb6f8a7e279afaf90cec961233.png" /home/anon/foo.png # ^ ...
user avatar
  • 183
0 votes
0 answers
105 views

Move files from one symlink directory to another symlink directory

I want to move files in a symlink directory to another symlink directory, e.g. suppose that I do have symlink a and b directories in the same level and a contains file.txt a/ |--- file.txt b/ ...
user avatar
2 votes
2 answers
186 views

What does `ln /path/to/file -i` do in a setuid'ed script?

I was making a Bash script with the setuid permission on, but it didn't work. So I found my solution here: Why does setuid not work? and Allow setuid on shell scripts Now my script works fine and ...
user avatar
  • 177
2 votes
1 answer
71 views

about ln command : condition of cross-device

On openSUSE Tumbleweed 20210606 with kernel GNU/Linux 5.12.9-1-default I tried making a hard link of file from /cust to ~/backup: df /cust && df ~/backup && ln -P /cust/customization....
user avatar
  • 23
-1 votes
2 answers
46 views

making a symlink based on corresponding file name

I want to create symlinks for my files (in total 350 files) cd ./my_files PD26400a.fixedheader.hs37d5.cram PD26400a.fixedheader.hs37d5.cram.crai ... I have a text file in which each file name in my ...
user avatar
  • 919
0 votes
0 answers
58 views

Symbolic link renaming backup files

I'm using backup files for when I create new symbolic link for files/folder. Because it's renaming existing symbolic files automatically on target folder like this : Let's say /home/main/Desktop is ...
user avatar
  • 1
1 vote
1 answer
35 views

correct way of storing external programm and making it executable?

I downloaded the CLI Client habash for the habit/routine gameification project habatica.com. In the fandom wiki for habash it is written that, I need to set environment variables. Additonally I want ...
user avatar
1 vote
1 answer
150 views

Help with script swapping target and symbolic links

I'm trying to create a script to swap the location of a symbolic link in the current directory and the target file in another (relative) directory. Unfortunately, I can't figure out how to make the ...
user avatar
3 votes
3 answers
381 views

Why didn't inode change anymore with a hard link

I use Vim 8.2 to edit my files in my Ubuntu 18.04. When I open a file, do some changes and quit with Vim, the inode number of this file will be changed. As my understanding, it's because the backup ...
user avatar
  • 2,879
0 votes
1 answer
26 views

Linking to files online

Is is possible to soft-link to a file on a web server? For example, if I have files hosted on localhost, is there a way to make ln -s http://localhost/file.txt ~/myremotefile.txt work as possible? I ...
user avatar
  • 125
0 votes
1 answer
77 views

What is the usage of -F option in ln command on FreeBSD?

In https://www.freebsd.org/cgi/man.cgi?ln, it says -F If the target file already exists and is a directory, then remove it so that the link may occur. The -F option should be used ...
user avatar
  • 111
1 vote
1 answer
476 views

Is there a standard Linux utility to generate shared library symlinks?

In an embedded environment that I'm working in, the following files are present: lrwxrwxrwx 1 root root 19 Aug 23 2016 /usr/lib/x86_64-linux-gnu/libjsoncpp.so.1 -> libjsoncpp.so.1.7.4 -rw-r--r-...
user avatar
  • 1,331
0 votes
1 answer
76 views

What is this and how do I delete it?

This is on my MacOS shell. I can't delete X11R6@ and I don't know what it is. Help?
user avatar
  • 627
-2 votes
2 answers
45 views

How can i move from one directory to another using the command ln and a relativ path in linux

My problem is that I need to move from a directory to another one by only using the ln command So here I have this relative path: ../../10/wsl and I know I have to create a symlink with ln to be able ...
user avatar
0 votes
1 answer
83 views

How to correct a link... Or is it a GNOME Desktop menu entry?

Few days ago, I've downloaded IntelliJ in my Downloads folder. I've executed bin/idea.sh installed it, and a convenient icon became available in my GNOME Desktop named IntelliJ, and was shown whenever ...
user avatar
  • 757
0 votes
0 answers
149 views

Move files & folders and Symlink

I am looking for a way to exclude some files/folder and mass move files/folders with spaces and special characters from source to destination and then symlink after move completes. So far I have ...
user avatar
0 votes
1 answer
99 views

Why does ln -s create a directory if soft-link exists?

I ran this command ln -s /folder1/dir /folder2/soft_link which did create a soft-link file where /folder2/soft_link pointed to /folder1/dir. But I notice when I run that same command again, it ...
user avatar
  • 155
0 votes
1 answer
146 views

Create a symbolic link containing certain subdirectories

Assuming I have the following directories: /source/dir1/sub1 /source/dir1/sub2 /source/dir1/sub3 /source/dir1/sub4 /source/dir2/sub1 /source/dir2/sub2 /source/dir2/sub3 /source/dir2/sub4 ... (...
user avatar
0 votes
0 answers
48 views

How to copy files from linux rhel6 to another rhel6 (which are not connected)?

How to copy files or folders from linux rhel6 server to another (which are not connected) with same file or folder properties (especially symlinks) using zip? The only way is FTP to server1 and copy ...
user avatar
0 votes
1 answer
697 views

What does the -fs flag do in the ln command?

came across this line in a code base today ln -fs /tmp/Cargo.lock . and I couldn't find the -fs argument anywhere in man ln. What does it do? P.S. The project runs this command inside of a docker ...
user avatar
1 vote
0 answers
100 views

Is there a path length limit for the soft link in ext2 file system?

I am working on a project for the educational purpose which I wrote an ln Linux command in c for the ext2 file system. I was trying to handle the case where the length of the src path for ln -s is ...
user avatar
  • 11
0 votes
1 answer
4k views

ls -a lists files with "->" arrow I think they are linked how can I make my new file to change when referenced file is changed?

I have following files: dirA/reference-file.ts dirB/new-file.ts I want new-file.ts to always change its content to match exact content as reference-file.ts when reference is changed. For example ...
user avatar
5 votes
1 answer
3k views

What is `ln --no-dereference` supposed to do?

I'm refreshing my understanding of a few basic GNU/Linux commands that I admit that I never really understood fully for the last 20+ years. $ man ln in part says: -n, --no-dereference treat ...
user avatar
5 votes
1 answer
7k views

Why permission denied upon symbolic link update to new target with permissions OK?

On a Linux machine (a computing cluster, actually), I copied a folder from another user (who granted me permissions to do so using the appropriate chmod). This folder contains symbolic links to files ...
user avatar
  • 229
0 votes
2 answers
384 views

How can i create symbolic link for directory

I am trying to create symbolic link as below ln -s /home/scripts/logs /home/log The directory /home/log is already existing ,which cant be deleted. When i do this it creates the symbolic link as /...
user avatar
  • 125
2 votes
3 answers
1k views

link config files

Problem I'm trying to move my config files from a .dotfiles folder, and link those files to the corresponding config path. Example In this example I'm trying $ ln -s ~/.dotfiles/nvim/init.vim ~/....
user avatar
0 votes
1 answer
134 views

Run node script with a global variable

I have a node script index.js with a node_modules folder. /script/myTestJscript/index.js /script/myTestJscript/node_modules /script/myTestJscript/package.json I could run the script with the command ...
user avatar
  • 1
2 votes
1 answer
833 views

What does "ln -t" do [duplicate]

What does ln -T do? I know the flag does not exist in the BSD version of ln, and it only exists in the GNU version, and I have read the documentation that it will make ln "treat LINK_NAME as a normal ...
user avatar
  • 211
81 votes
14 answers
7k views

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 ...
user avatar
  • 2,225
3 votes
3 answers
2k views

Recursively "find" file names containing string and symlink files in another directory

I am trying to symlink a set of specific files from a project I'm working on. There is a known string in each of the filenames I wish to symlink. Here is what I have so far: ln -s find ~/path/to/...
user avatar
4 votes
1 answer
4k views

Is there a way to create a symlink to a non-existent target?

Is there a way to create a symlink whose target does not exist using shell scripts? From reading man 1 ln, I do not see an option to do so; and even -f checks if the target exists. Is there a way to ...
user avatar
0 votes
1 answer
139 views

Make a `ln -s` that checks for broken symbolic links

I am trying to write a function ln() (if it is not a good idea to call it ln, it may just be as well called myln() or whatever, but that is not important) in bash, such that, If the short option -s ...
user avatar
  • 3,036
12 votes
3 answers
35k views

How to create a folder symlink that has a different name?

I want to create a symlink ~/.pm2/logs -> /opt/myapp/log When I run ln -sFf /opt/myapp/log ~/.pm2/logs I get a symlink ~/.pm2/logs/log -> /opt/myapp/log which is not what I want. I'd ...
user avatar
  • 223
0 votes
1 answer
497 views

I want to make symlinks of all files in a directory EXCEPT the existing symlinks in the directory

I have a bash script that creates symlinks from the directories in one users directory to another users directory. I want the script to exclude existing symlinks in the source directory when creating ...
user avatar
0 votes
2 answers
1k views

How to regularly update symbolic link (ln -sf) via crontab

Background The PNG image files I want to use is stored in directories according to date, for example: /NAS-mein/data/201812/ PNG stored within it like /NAS-mein/data/201812/foo/bar/20181231_1500....
user avatar
  • 3
0 votes
1 answer
184 views

create symlinks by dropping version number

I have large number of shared libraries like this: libexpat.so.1.6.7 libqquicklayoutsplugin.so libstdc++.so.6.0.24 libexportlib.so.1.0.0 libqsvg.so ...
user avatar
  • 1,335
4 votes
1 answer
3k 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 &...
user avatar
1 vote
1 answer
2k 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 $ ...
user avatar
  • 2,331
5 votes
2 answers
2k 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 ...
user avatar
  • 1,875
1 vote
1 answer
537 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 ...
user avatar
2 votes
3 answers
4k 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/...
user avatar
0 votes
2 answers
1k 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 ...
user avatar
  • 2,321