LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-16-2015, 06:19 AM   #1
abefroman
Senior Member
 
Registered: Feb 2004
Location: lost+found
Distribution: CentOS
Posts: 1,401

Rep: Reputation: 55
ln with -t option, to create relative symlink not working


I'm trying to recreate a relative symlink, to link "asymlink" to "somedir/actualfile" in /root/test/ but its creating 2 symlinks instead.

Code:
[root]# ln -t /root/test/ -s somedir/actualfile asymlink
[root]# ll /root/test/
total 4
lrwxrwxrwx 1 root root   18 Feb 16 06:15 actualfile -> somedir/actualfile
lrwxrwxrwx 1 root root    8 Feb 16 06:15 asymlink -> asymlink
drwxr-xr-x 2 root root 4096 Feb 16 06:15 somedir
I can do it with
Code:
cd /root/test
ln -s somedir/actualfile asymlink
but I'm trying to avoid the cd, and also avoid using the full path.

Does anyone know why the -t flag isn't working as expected?
 
Old 02-16-2015, 06:31 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,440

Rep: Reputation: 2772Reputation: 2772Reputation: 2772Reputation: 2772Reputation: 2772Reputation: 2772Reputation: 2772Reputation: 2772Reputation: 2772Reputation: 2772Reputation: 2772
ln <source file> -s <target file>
use both source and target with full path
Is that what you are looking for?
 
Old 02-16-2015, 06:37 AM   #3
millgates
Member
 
Registered: Feb 2009
Location: 192.168.x.x
Distribution: Slackware
Posts: 840

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
From man ln:

Code:
SYNOPSIS
       ln [OPTION]... [-T] TARGET LINK_NAME   (1st form)
       ln [OPTION]... TARGET                  (2nd form)
       ln [OPTION]... TARGET... DIRECTORY     (3rd form)
       ln [OPTION]... -t DIRECTORY TARGET...  (4th form)
You are using the 4th form. Both "somedir/actualfile" and "asymlink" are treated as targets. You can't both use -t and specify link name.
You can do the following, though, to avoid the cd:

Code:
ln -s somedir/actualfile /root/test/asymlink
 
1 members found this post helpful.
Old 02-16-2015, 06:57 AM   #4
abefroman
Senior Member
 
Registered: Feb 2004
Location: lost+found
Distribution: CentOS
Posts: 1,401

Original Poster
Rep: Reputation: 55
Code:
ln -s somedir/actualfile /root/test/asymlink
That worked, thanks!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
can not find root file. create symlink chiko987 Fedora - Installation 2 11-04-2009 07:39 AM
can't create symlink to my home path nick623 Linux - General 13 02-13-2006 09:36 PM
How do I create a symlink? mouldy_punk Linux - General 6 01-12-2006 02:55 PM
What is a symlink and how do I create one. Zog_dev Linux - General 2 09-10-2003 03:08 PM
create symlink with an option,e.g. gunzip & gzip,how? l_9_l Linux - General 1 05-15-2002 03:59 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:55 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration