Linux: Create Symlink to a File
Question by Guest | 2017-06-26 at 16:18
I would like to create a symbolic link (symlink) to one of my files via a script. Therefore, I am searching for a bash command for the terminal that can create such a linkage for me. Can someone help me?
Related Topics
Windows: Create Symlink to a File
Question | 1 Answer
Rename File to its Folder Name
Tutorial | 0 Comments
How to resize Image before Upload in Browser
Tutorial | 13 Comments
PHP: File Download Script
Tutorial | 0 Comments
Release of Debian Packages, RPM Packages and Binaries for Linux
Blog | 0 Comments
Linux: Mark Program File as executable
Tutorial | 0 Comments
Lazarus: Load File as Byte Array and save Byte Array as File
Tutorial | 0 Comments
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.
Links can be created using the command ln. By default, ln creates a hard link. For creating symbolic links, you have to pass the parameter s:
As you can see, after ln -s, you are first passing the path to the file that should be linked and then the path to the symlink that should be created. The symlink should not exist yet, because otherwise you would get an error message.
If the symlink is already existing and you want to change or update the link to the file, you can do that with the following line:
The "f" means force and takes care of that an existing target file / symlink will be deleted before creation. If you are using the -sf option and the symlink is not existing, also -sf is just creating a new symlink. So, you can also use this option if you do not know whether there is an already existing symlink or not.
2017-06-26 at 23:30