Command Line

Let’s Make A Symbolic Link

In this article, we’re going to learn how to make a symbolic link. This will be a very easy article, and one you may get some use from. It’s not terribly hard to make a symbolic link, though I suppose the syntax may seem quirky as compared to many other commands. It’s not hard, trust me on this… Or not… You can pretend it’s hard and impress your friends and family!

Ah well…

So, what’s a symbolic link? Well, it’s a link to another file. A symbolic link is a file that contains nothing more than a link to another file. There’s a hard link as well, and that points to an inode. A symbolic link is a bit more versatile. You can make a symbolic link (again, a file) and move it around the system and it’ll still point at the original file. It’s useful if you want to do things like put shortcuts on your desktop.

This being Linux, everything is a file. A symbolic link is a file. It is a file that contains information about where another file is located. Some folks think this sort of stuff is complicated, perhaps too complicated for a new Linux user, but I think it’s easy – so long as it’s properly explained. Darned if I know how to explain it! I hope that worked for you. That’s really all it is. That’s it. It’s just a file that contains information about where another file is located. Everything is a file.

Like I said, this is going to be a short article. It really shouldn’t be all that difficult to show you how to …

Make A Symbolic Link:

This article requires an open terminal, like many other articles on this site. If you don’t know how to open the terminal, you can do so with your keyboard – just press CTRL + ALT + T and your default terminal should open.

Now, pick a file… One that most users will have will be your Bash history, located at ~/.bash_history unless you’ve really done some heavy modifications. Let’s use that file to make a symbolic link.

The format to do this is:

ln -s <existing_file> <new_file>

Obviously, the -s means ‘symbolic’ (feel free to check ‘man ln‘ for more information) and you name the existing file first and then the file you want to create. So, to do this with .bash_history, it’d look like:

ln -s ~/.bash_history ln_test

Now, you can see it in action:

cat ~/ln_test

Tada! It will show the contents of your .bash_history if you did everything correct. Want to see something even more handy?

mv ~/test ~/Desktop

Now, look at  your desktop and open the file named ‘test’ – or just navigate there in your terminal and check it again with the cat command:

cd ~/Desktop && cat test

Congratulations! You’ve learned how to make a symbolic link! I told you that it wasn’t all that hard. As a concept, it’s even easier to understand. The syntax to do so isn’t even all that difficult. You’ve got this! I have faith!

Closure:

Yes, yes I did say this would be quick and easy. I think it was. It’s not terribly hard to make a symbolic link and it was a fun article to write. It’s fun to cover some of the basics. As the tagline says, “Getting you up to speed!” Search around or just browse, you might be amazed at the subjects covered!

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

KGIII

Retired mathematician, residing in the mountains of Maine. I may be old and wise, but I am not infallible. Please point out any errors. And, as always, thanks again for reading.

Recent Posts

How To: Install Wine In Lubuntu

Today's article isn't going to be complicated or long as we are going to cover…

4 mins ago

Update Python Packages (PIP)

We've had a run of Python packages recently and you can tell that I'm a…

2 days ago

Save A Command’s Output To A File (While Showing It In The Terminal)

The title is the best I can come up with to describe this exercise as…

4 days ago

Demystifying journalctl: A Comprehensive Guide to Linux System Logging

It was suggested that I write an article about journalctl, which seemed like a large…

6 days ago

Extract Text From Multiple File Types

Today we will have a fairly simple exercise as we're going to just use a…

1 week ago

Meta: I’ve Been At This For Three Years!

I have not done a meta article lately. I don't find them interesting to write…

1 week ago