/ factorpad.com / tech / linux-essentials / ln-command.html
An ad-free and cookie-free website.
Beginner
Learn to make file or directory links at the Linux command line.
Videos can also be accessed from the Linux Essentials Playlist on YouTube.
Linux ln Command Summary with Examples (3:57)
Our twenty-first word, or command to memorize is ln
from the category
System.
ln
allows you to make file or
directory links.
-options | description |
---|---|
--help |
Print help screen |
-s , --symbolic |
Set up a symbolic link instead of a hard link |
Recall from the last video (tutorial) we saw a connection between the
command nano
to
pico
and here we'll sort that out.
Before we start, it helps to think about commands as mini programs and
most follow this structure:
command -option(s) argument(s)
.
The ln
command has
16 options and there are typically two arguments,
the target file and the link name,
which is the pointer.
Like most commands, help is available, here with double-dash
--help
.
Because the concept of links can be difficult, for now I'd just like to
draw your attention to the -s
option,
for symbolic links.
So why is ln
an important command?
Well, ln
is widely used on your
system already, and you will need to establish links.
And now you know how to do that.
Okay, the best way to embed this in your memory is by typing in your own terminal window.
Find this on your Mac using a program called Terminal. On Linux use Terminal or Konsole, and currently Microsoft is adding this functionality to Windows.
Here we go, using the echo
command
from video 19, let's "make up words"
,
create a file >
, and put it in the
directory one above here ../
, giving
it a ridiculouslylongfilename.txt
.
So to avoid typing that and wasting time, let's make a symbolic link,
using ln -s
, the
target
../ridiculouslylongfilename.txt
, then
the link name
video21.txt
.
List files ls
.
There it is, in a different color (bold here), and use
cat
from video 10 to view (the
symbolic link).
And last, let's revisit the nano/pico
topic from earlier. Let's do a whatis
on the commands.
Basically, behind the scenes is a (symbolic) link pointing
pico
to open
nano
and this is where my system
does that.
Again, links are very common, so we'll revisit the topic again later.
Okay now you know how to use ln
.
And you know the syntax for commands, options and arguments.
One last tip about the ln
command.
The two link types: symbolic (soft) and hard, are worth knowing, so
please read the help file.
Okay, great, thanks for visiting today. I hope this was a fun
introduction to the ln
command.
For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:
Reach out to us with questions and comments at YouTube. Subscribe and follow @twitter for new content announcements.
nano
command,
hit Back.mkdir
, click Next./ factorpad.com / tech / linux-essentials / ln-command.html
A newly-updated free resource. Connect and refer a friend today.