Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
11-12-2006, 12:21 PM
|
#1
|
Senior Member
Registered: Jul 2004
Location: Germany
Distribution: open SUSE 11.0, Fedora 7 and Mandriva 2007
Posts: 1,666
Rep:
|
The command to make a symbolic link
[Nissanka@c83-250-99-43 ~]$ ls
Desktop
Documents
E1.odt
GPG1.odt
[Nissanka@c83-250-99-43 ~]$ cd Documents
[Nissanka@c83-250-99-43 Documents]$ ls
CDcontents Linux_Forum_Questions
[Nissanka@c83-250-99-43 Documents]$
[root@c83-250-99-43 Nissanka]# ln -s /Documents/CDcontents/VPN.txt
[Nissanka@c83-250-99-43 ~]$ ls
Desktop
Documents
E1.odt
GPG1.odt
VPN.txt
[The above shows that the 'ln' command worked fine because the file 'VPN.txt' is visible.]
[Nissanka@c83-250-99-43 ~]$ cat VPN.txt
cat: VPN.txt: No such file or directory
[Nissanka@c83-250-99-43 ~]$
[Nissanka@c83-250-99-43 ~]$ file VPN.txt
VPN.txt: broken symbolic link to `/Documents/CDcontents/VPN.txt'
[Nissanka@c83-250-99-43 ~]$
Inside the 'Documents' folder, there is another folder called 'CDcontents'
In the folder 'CDcontents' , I have a file called 'VPN.txt'.
I make a symbolic link of it. The 'ln' command worked fine.
However the 'file' command tells me it is a broken link and the 'cat' command tells me there is no file.
What is the problem here?
|
|
|
11-12-2006, 12:23 PM
|
#2
|
LQ Addict
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464
Rep: 
|
When you use ln, you need to provide both the source (i.e. the file you're making a link to) and the destination (i.e. the actual link). See the man page for ln..
|
|
|
11-12-2006, 12:41 PM
|
#3
|
Senior Member
Registered: Jul 2004
Location: Germany
Distribution: open SUSE 11.0, Fedora 7 and Mandriva 2007
Posts: 1,666
Original Poster
Rep:
|
Thanks Nylex. I looked at the man pages. I don't like man pages, in first place.
It is written in the best unimpressive language.
I created a file called 't1'. I used the command 'touch' for the creation of this file.
[Nissanka@c83-250-99-43 ~]$ touch t1
[Nissanka@c83-250-99-43 ~]$ ls
Desktop
Documents
E1.odt
GPG1.odt
t1
[Here you see the new file 't1' .]
[Nissanka@c83-250-99-43 ~]$ ln -s t1 /Documents/CDcontents/VPN.txt
ln: creating symbolic link `/Documents/CDcontents/VPN.txt' to `t1': No such file or directory
[Nissanka@c83-250-99-43 ~]$
What is the problem now?
Last edited by Gins; 11-12-2006 at 12:42 PM.
|
|
|
11-12-2006, 12:54 PM
|
#4
|
Senior Member
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113
Rep: 
|
ln -s t1 Documents/CDcontents/VPN.txt
If ~/Documents is your target, you mean a relative path - you're giving an absolute with a 'Documents' directory off /.
|
|
|
11-12-2006, 01:02 PM
|
#5
|
Senior Member
Registered: Jul 2004
Location: Germany
Distribution: open SUSE 11.0, Fedora 7 and Mandriva 2007
Posts: 1,666
Original Poster
Rep:
|
Thanks digiot for the comments. However, I can't fathom out your comments.
The following didn't work.
[root@c83-250-99-43 Nissanka]# ln -s t1 Documents/CDcontents/VPN.txt
ln: creating symbolic link `Documents/CDcontents/VPN.txt' to `t1': File exists
[root@c83-250-99-43 Nissanka]#
----------------------------------------------------------------------------------------------------------
[root@c83-250-99-43 Nissanka]# cat t1
[root@c83-250-99-43 Nissanka]#
[root@c83-250-99-43 Nissanka]# file t1
t1: empty
[root@c83-250-99-43 Nissanka]#
Last edited by Gins; 11-12-2006 at 01:07 PM.
|
|
|
11-12-2006, 01:17 PM
|
#6
|
Senior Member
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113
Rep: 
|
There are several ways to specify paths:
/Documents/CDcontents/VPN.txt # absolute, meaning 'ls /' would show 'Documents bin' and so on.
Documents/CDcontents/VPN.txt # relative, meaning 'ls' would show 'Documents' and so on. Relative from current.
../Documents/CDcontents/VPN.txt # relative, meaning 'one directory above'
You're describing a path that starts at the root directory '/' when it's actually /home/Nissanka/Documents.
As far as the 'file exists', you need to either 'rm' t1 or 'ln -sf' to force the link. A link would specify an existing file first and a non-existent link last. So, come to think of it, I guess you want:
ln -s Documents/CDcontents/VPN.txt t1
Hope that's clearer, though I'm not sure it is.
-- I'm assuming here that 'ls ~/Documents/CDcontents/VPN.txt' shows a file you want to link to and '~/t1' is the link you want to make and either doesn't exist or has no content. The command(s) I gave should work for that. If not, I'm misunderstanding your objective and you could try to explain it to me again.
Last edited by slakmagik; 11-12-2006 at 01:26 PM.
|
|
|
11-12-2006, 01:30 PM
|
#7
|
Senior Member
Registered: Jul 2004
Location: Germany
Distribution: open SUSE 11.0, Fedora 7 and Mandriva 2007
Posts: 1,666
Original Poster
Rep:
|
[root@c83-250-99-43 Nissanka]# rm t1
rm: remove regular empty file `t1'? y
[root@c83-250-99-43 Nissanka]#
I removed the file.
-----------------------------------------------------
[root@c83-250-99-43 Nissanka]# ls
Desktop
Documents
E1.odt
GPG1.odt
[So it is removed. You don't see it.]
---------------------------------------------------------
Then I created again.
[root@c83-250-99-43 Nissanka]# touch t1
[root@c83-250-99-43 Nissanka]#
----------------------------------------------------------
[root@c83-250-99-43 Nissanka]# ls
Desktop
Documents
E1.odt
GPG1.odt
t1
[ Now it is there again.]
------------------------------------------------
[root@c83-250-99-43 Nissanka]# ln -s Documents/CDcontents/VPN.txt t1
ln: creating symbolic link `t1' to `Documents/CDcontents/VPN.txt': File exists
[root@c83-250-99-43 Nissanka]#
----------------------------------------------------
[root@c83-250-99-43 Nissanka]# cat t1
[root@c83-250-99-43 Nissanka]# file t1
t1: empty
[root@c83-250-99-43 Nissanka]#
What is the problem now?
|
|
|
11-12-2006, 01:34 PM
|
#8
|
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809
|
Quote:
Originally Posted by Gins
Thanks Nylex. I looked at the man pages. I don't like man pages, in first place.
It is written in the best unimpressive language.
|
I would recommend that you get over this....Very often, the man pages will give you the answer in a flash---as a minimum, they will remind of what you have already read in a good manual or tutorial.
I think you have already been given the anwsers, but: - ln -s will happily make a bad link if the syntax is wrong.
- ln -s is picky about path specifications: The safest way is to always give full paths. You can link INTO a directory--eg: "ln -s /dir1/dir2/filename linkname. I think that linking OUT can cause problems. AND--isn't there something about soft linking across partitions/drives??
Try your particular case first with full path names--just to be sure that that part works.
Recommended reading:
Bash Guide for Beginners, Machtelt Garrels Get it from: tldp.org
Linux in a Nutshell, published by O'Reilly (avail. thru Safari??)
Last edited by pixellany; 11-12-2006 at 01:36 PM.
|
|
|
11-12-2006, 01:38 PM
|
#9
|
Senior Member
Registered: Jul 2004
Location: Germany
Distribution: open SUSE 11.0, Fedora 7 and Mandriva 2007
Posts: 1,666
Original Poster
Rep:
|
Now I got it working.
You don't have to create a file called 't1'.
The following worked beautifully.
ln -s Documents/CDcontents/VPN.txt t2
The system creates automatically file t2.
The 'cat' command and the 'file' command worked.
[root@c83-250-99-43 Nissanka]# file t2
t2: symbolic link to `Documents/CDcontents/VPN.txt'
[root@c83-250-99-43 Nissanka]#
|
|
|
11-12-2006, 01:52 PM
|
#10
|
Senior Member
Registered: Jul 2004
Location: Germany
Distribution: open SUSE 11.0, Fedora 7 and Mandriva 2007
Posts: 1,666
Original Poster
Rep:
|
Pixellany
As far as I am concerned, the f...... man pages are boring.
They don't write in a user friendly manner. Their language is boring. Did you study networking? I did study networking. If you look at the books written by Cisco on networking, you will notice the difference. Those big books are written by some Americans,I believe. They know how to write in simple and beautiful English.
I bought about 25 books published by Cisco on networking. I paid thousands of money to buy those books.
It goes same with the books written by Microsoft on Windows 2003 server. They know how to write in simple language.
However, I would respect to your opinion on man pages. It seems you find them interesting.
I always consult the following website to find details.
http://www.computerhope.com/unix/uln.htm
It is written in simple and attractive English. You could write books or articles. You should be able to write so as to get the attention of the reader.
|
|
|
11-12-2006, 01:58 PM
|
#11
|
Senior Member
Registered: Jul 2004
Location: Germany
Distribution: open SUSE 11.0, Fedora 7 and Mandriva 2007
Posts: 1,666
Original Poster
Rep:
|
Pixellany
You created this 'CDcontents' folder nearly a week ago.
Do you recall it? I was trying to copy an entire CD on to a folder. You helped me.
For me, you are a clever man.
|
|
|
All times are GMT -5. The time now is 03:58 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|