Questions tagged [ln]
ln - Command line tool to create hard links to existing files and soft links to existing and non-existent files.
142
questions
4
votes
1
answer
189
views
ln will not create symlinks to nonexistent targets / target without permission
First of all please note that I'm on a shared server and I don't have root access, so anything involving su or sudo would not be possible.
AFAIK ln and Linux should not even bother checking whether ...
0
votes
3
answers
56
views
Is there a shortcut to denote the absolute full directory of current path? [duplicate]
Let's say that I am currently in /a/b/c/d/e/, and I want to make symbolic link with a file f.txt in that directory. If I do ln -s f.txt /etc/, the file /etc/f.txt will not point to the file, because ...
1
vote
1
answer
267
views
Symlink creating a nested subdirectory
I don't understand what I'm doing wrong today with trying to create.
Inside my current directory, I recreated an empty directory called input. I would like to symlink this to
../../../../opt/build/db/...
2
votes
2
answers
96
views
How can I copy directories recursively with hardlinks with variables in bash?
The operation I'm trying to do is take directory 1:
Dir1
Dir A
File A
Dir B
File B
Then use the find command to check every file in Dir 1 for whether or not they have an ...
0
votes
1
answer
131
views
What does "resolve symlink" mean?
Im confused about this bash option:
-P
If set, do not resolve symbolic links when performing commands such as cd which change the current directory. The physical directory
is used instead. By default,...
0
votes
1
answer
26
views
Why when i copy file from a symlink directory one level up copy is created one level up from original directory?
user@DESKTOP-KK4CCE2:~$ mkdir -p ~/foo/bar/
user@DESKTOP-KK4CCE2:~$ touch ~/foo/bar/test.txt
user@DESKTOP-KK4CCE2:~$ mkdir ~/baz/
user@DESKTOP-KK4CCE2:~$ ln -s ~/foo/bar/ ~/baz/bar
user@DESKTOP-...
-2
votes
1
answer
173
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 ...
0
votes
1
answer
371
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 ...
0
votes
1
answer
73
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 ...
1
vote
1
answer
128
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 ...
2
votes
0
answers
78
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 ...
0
votes
0
answers
237
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 ...
1
vote
1
answer
500
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. ...
0
votes
1
answer
236
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
...
0
votes
1
answer
877
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
# ^ ...
0
votes
0
answers
466
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/
...
2
votes
2
answers
227
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 ...
2
votes
1
answer
232
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....
-1
votes
2
answers
201
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 ...
0
votes
0
answers
114
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 ...
1
vote
1
answer
44
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 ...
1
vote
1
answer
305
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 ...
3
votes
3
answers
526
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 ...
0
votes
1
answer
29
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 ...
0
votes
1
answer
122
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 ...
1
vote
1
answer
1k
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-...
0
votes
1
answer
79
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?
-1
votes
2
answers
68
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 ...
0
votes
1
answer
160
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 ...
0
votes
0
answers
194
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 ...
0
votes
1
answer
556
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 ...
0
votes
1
answer
407
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
... (...
0
votes
0
answers
60
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 ...
0
votes
1
answer
1k
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 ...
0
votes
1
answer
5k
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 ...
8
votes
1
answer
5k
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 ...
5
votes
1
answer
16k
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 ...
0
votes
2
answers
1k
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 /...
3
votes
3
answers
2k
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 ~/....
0
votes
1
answer
221
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 ...
2
votes
1
answer
1k
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 ...
89
votes
13
answers
10k
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 ...
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/...
3
votes
1
answer
7k
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 ...
0
votes
1
answer
165
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 ...
17
votes
3
answers
41k
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 ...
0
votes
1
answer
575
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 ...
1
vote
2
answers
2k
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....
0
votes
1
answer
277
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 ...
4
votes
1
answer
4k
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 &...