Creating a symlink

Creating a symlink

I have now been fully using Manjaro Linux for around eight months now. Mostly never having to use my Windows 10 except for the program Garmin Express that I need sometimes. Here’s my post about me finally leaving Windows to Linux

Today I wanted to create a symlink (symbolic link) from an original file in a folder to another folder

In Manjaro Linux and probably other Linux distribs wallpapers are in more than one folder. The original files and symlinks are in different folders

I’d added a wallpaper image that I wanted to use in my /usr/share/backgrounds/wallpapers-2018/  folder and I wanted to add the symlink link to the /usr/share/backgrounds/xfce/ as this folder contained symlinks of all the original files in the wallpaper-2018 folder. Why? I do not know. But as it must be of use somewhere and as I like playing and learning I thought that I would create the symlink

Linux is not Windows…

Of course. Linux not being Windows the copy, and or drag and drop doesn’t work as it needs root permissions.

So a quick Google around showed me that I needed the ln -s command in terminal.

Terminal is your friend

So I typed in terminal what I had learned :

sudo ln -s /usr/share/backgrounds/wallpapers-2018/Wallpaper_1.jpeg /usr/share/backgrounds/xfce/

This is just sudo ln -s ‘source’ ‘target’

sudo so that it will ask your password when you hit the Ok button.
The Source being where your original file is. My complete address (/usr/share/backgrounds/wallpapers-2018/Wallpaper_1.jpeg)
The Target being where you want the symlink to be created (/usr/share/backgrounds/xfce/)

This effectively created a symlink in my target/destination folder /usr/share/backgrounds/xfce/ but I noticed that it was different from the other files having the little ‘arrow’ but also a ‘cross’, and when checking found that it was a ‘broken’ symlink. So it still was correct.

Now I had to delete this file. Doh I need to have root permission to do that ….
So I opend a teminal and typed in
sudo rm /usr/share/backgrounds/xfce/Wallpaper_1.jpg
Careful here rm is a very dangerous command. It deletes, full stop, it doesn’t ask are you sure etc etc

Hours later. Many google pages later I came across an article saying that I had to ‘be in’ the target/destination folder when doing the ln -s command for it to work.

Terminal is still your friend

Ok that’s fairly easy. So in the terminal I just typed
cd /usr/share/backgrounds/xfce/ (my target folder where I wanted the symlink to be)

Now being in the target folder I redid the
sudo ln -s /usr/share/backgrounds/wallpapers-2018/Wallpaper_1.jpeg /usr/share/backgrounds/xfce/

Creating a symlink : YES my symlink file was now created correctly and this time only having the little arrow showing me that it was a symlink and correctly linked to the original file. Oh yes 🙂

So fairly easy, except having to know that I had to cd to be in my target folder for the symlink to be correctly created.

Hoping that this might save you some hours of googling around….

Here are two sites that I came across that also help and explain Creating a symlink, and probably better than me

Again I’m a beginner in Linux. I use it / play with it and sometimes find things that should be easy but aren’t and are as clear as mud. So I hope that this helps.