LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch
User Name
Password
Linux From Scratch This Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.

Notices


Reply
  Search this Thread
Old 03-30-2018, 09:35 AM   #1
whjeon
Member
 
Registered: Feb 2018
Location: Seoul,South Korea
Distribution: Debian
Posts: 88

Rep: Reputation: Disabled
LFS-8.2 Ch4.2. Creating Symlink Question


Dear Mentors. WHJeon again!

After successful installation of LFS & BLFS several times, I started to study slowly with every commands.

Now, in Ch4.2. Creating the $LFS/tools directory, there is symlink command.
Code:
 #ln -sv $LFS/tools /
And then succeeded message follows
Code:
'/tools' -> '/mnt/lfs/tools'
In the book, there's also note that this is right command, and if I have any doubt, read the man ln(1) and info coreutils. I looked through and couldn't found any related information.

-s : symbolic, -v : verbose.

What I'm curious is that isn't above command create symlink from '/' directory? How 'ln'command guess it should be '/tools'?

Thanks for reading! Please Help me!
 
Old 03-30-2018, 10:00 AM   #2
spiky0011
Senior Member
 
Registered: Jan 2011
Location: PLANET-SPIKE
Distribution: /LFS/Debian
Posts: 2,511
Blog Entries: 1

Rep: Reputation: 412Reputation: 412Reputation: 412Reputation: 412Reputation: 412
It uses the name from where your linking it.

if you had put /test1 it would of created a link test1 > /mnt/lfs/test

Sorry if not explain very well but try it and see

ln -sv $LFS/tools /test1
 
Old 03-30-2018, 11:00 AM   #3
whjeon
Member
 
Registered: Feb 2018
Location: Seoul,South Korea
Distribution: Debian
Posts: 88

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by spiky0011 View Post
It uses the name from where your linking it.

if you had put /test1 it would of created a link test1 > /mnt/lfs/test
I already know that, and becuase of that, I had this question.
As you said, I typed
Code:
 #ln -sv $LFS/tools /
I expected '/' -> '/mnt/lfs/tools', not '/tools' -> '/mnt/lfs/tools'/.
How this happened?
 
Old 03-30-2018, 11:44 AM   #4
Mill J
Senior Member
 
Registered: Feb 2017
Location: @127.0.0.1
Distribution: Mint, Void, MX, Haiku, PMOS, Plasma Mobile, and many others
Posts: 1,258
Blog Entries: 2

Rep: Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542
Well for example:
Code:
cp junk.txt /
would create a junk.txt in the / directory. If you don't specify a different name it will use the name of the source file/folder.

And being the command created a symlink called /tools that points(->) to '/mnt/lfs/tools' it is telling you exactly what it did.
 
Old 03-30-2018, 11:53 AM   #5
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,572
Blog Entries: 19

Rep: Reputation: 4451Reputation: 4451Reputation: 4451Reputation: 4451Reputation: 4451Reputation: 4451Reputation: 4451Reputation: 4451Reputation: 4451Reputation: 4451Reputation: 4451
It's simple. A symbolic link must be a file. It cannot be a directory. It can point to a directory but the link itself must be a file.

/ is a directory so its name is not available for use as a link. The ln command has a standard response to this type of instruction: it treats it as an instruction to create a link within the specified directory. As no name for the link file itself has been given, it defaults to the local name of the target, in this case the /tools directory.
 
1 members found this post helpful.
Old 03-30-2018, 07:13 PM   #6
whjeon
Member
 
Registered: Feb 2018
Location: Seoul,South Korea
Distribution: Debian
Posts: 88

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by hazel View Post
It's simple. A symbolic link must be a file. It cannot be a directory. It can point to a directory but the link itself must be a file.

/ is a directory so its name is not available for use as a link. The ln command has a standard response to this type of instruction: it treats it as an instruction to create a link within the specified directory. As no name for the link file itself has been given, it defaults to the local name of the target, in this case the /tools directory.
Thanks!! I didn't know that!! Thanks again
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Problem creating symlink with gcc to libgcc.a in LFS v6.7 linuxpicaxe Linux - Software 4 03-06-2011 12:24 PM
Problem creating symlink with gcc to libgcc.a in LFS v6.7 nuainkyeuh Linux From Scratch 4 02-28-2011 12:26 PM
Question How to get stat() of symlink and not of target of symlink ? ronbarak Programming 3 11-08-2010 12:14 PM
question about creating the "linux" symlink when compiling kernel newbiesforever Linux - General 1 01-19-2009 05:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch

All times are GMT -5. The time now is 11:17 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration