LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 01-31-2013, 07:31 PM   #1
doncristobal
LQ Newbie
 
Registered: Jan 2009
Posts: 4

Rep: Reputation: 0
Analogy to Windows shortcut that's NOT a symlink?


In Linux (more precisely in Xfce's Thunar), is there a way to create a link that does not create a new representation of already existing data but that simply makes me jump to the target?

An example: "$ ln -s /media/data/xyz ~/Desktop/xyz" creates a symbolic link to /media/data/xyz on my Desktop. Very fine. I can "$ cd ~/Desktop/etc/", or I can navigate to ~/Desktop/etc/, and maybe there is a big folder structure hidden in this xyz folder (~/Desktop/etc/gi/ga/gu/...).
But I'd like cd (or at least Thunar) to jump to /media/data/xyz! Is there any way to achieve this? It's what a Windows shortcut does, and it could be useful in some situations. [edit: as Grail pointed out, Windows only works like this in the gui. The Windows terminal can't handle .lnk files like this. See 3rd post.]

Oh, I'm /sure/ this question has been answered before, but I've spent quite a while searching...

Last edited by doncristobal; 02-01-2013 at 03:28 AM. Reason: revoking shockingly and naïvely positive statement about Windows' abilities ;-)
 
Old 01-31-2013, 09:02 PM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,011

Rep: Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194
I am confused by the following statement:
Quote:
I'd like cd (or at least Thunar) to jump to /media/data/xyz!
Where does cd or Thunar take YOU? Or are you more asking that once there and you do something like cd .. that it then takes you to /media/data?

Also, when making a claim, such as:
Quote:
It's what a Windows shortcut does
You may wish to provide exact details. I say this as I just created a shortcut to a directory on a Win XP machine which is on my desktop.
On traversing to the Desktop folder and issuing a cd command to the same lnk file created I receive:
Code:
c:\>cd "Documents and Settings\grail\Desktop"
c:\Documents and Settings\grail\Desktop>dir
 Volume in drive C has no label.
 Volume Serial Number is F401-FEEB

 Directory of C:\Documents and Settings\grail\Desktop

01/02/2013  10:35    <DIR>          .
01/02/2013  10:35    <DIR>          ..
31/08/2012  12:34               736 Notepad++.lnk
01/02/2013  10:35               352 Shortcut to grail.lnk
28/08/2012  11:35               570 SQL Developer.lnk
               3 File(s)          1,658 bytes
               2 Dir(s)  212,671,336,448 bytes free

c:\Documents and Settings\grail\Desktop>cd "Shortcut to grail.lnk"
The directory name is invalid.
So you may need to explain just how it works on Windows??
 
Old 02-01-2013, 03:25 AM   #3
doncristobal
LQ Newbie
 
Registered: Jan 2009
Posts: 4

Original Poster
Rep: Reputation: 0
Oh, I was not aware of the fact that the Windows terminal can't handle .lnk files. I was only thinking of the gui. Thank you, Grail, for this piece of information. So I fully take back the statement that I'd like to see original Windows (TM) behaviour. As usual, I'd like something _better_ than Windows ;-)
I'll give an example of what I'd /like/ to see:

Code:
~/Desktop$ ln -s /media/data/xyz
~/Desktop$ cd xyz
/media/data/xyz$
Instead I do see (the only difference is on the last line):

Code:
~/Desktop$ ln -s /media/data/xyz
~/Desktop$ cd xyz
~/Desktop/xyz$
Thunar closely follows this logic, i.e. it pretends there actually /are/ folders like ~/Desktop/xyz/gi/ga/gu

Why do I ask this question? I've created a similar symlink on my girlfriend's computer for her documents folder. Now I'd prefer her not to get confused with data existing in two separate places. However, sometimes she is bound to go to the original place as Thunar and encfs produce an error under the symlink in some circumstances. I hope my question is clearer now.

Last edited by doncristobal; 02-01-2013 at 11:33 AM. Reason: playing with layout... always learning a bit
 
Old 02-01-2013, 05:59 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,011

Rep: Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194
Ok ... so i played around a little (as this is not a feature I understand wanting) and found the following:
Code:
-P      If  set,  the shell does not follow symbolic links when executing commands such as cd that change the current working directory.  It uses the physical directory structure instead.  By default, bash follows the
                      logical chain of directories when performing commands which change the current directory.
So, if you create an alias for cd to now always execute cd -P you will follow the link to it's actual location. As for having your file manager follow the same process,
you will probably need to either find out how it currently performs the task and change it or go to their forums to see if it is possible without recoding / recompiling the code.

Hope that helps a little.

btw. I would point out it may just be easier to explain to your girlfriend that the data is in only one place but there are multiple ways to get there.
My mother was in her 60s when I switched her to Linux and she managed
 
Old 02-01-2013, 11:23 AM   #5
doncristobal
LQ Newbie
 
Registered: Jan 2009
Posts: 4

Original Poster
Rep: Reputation: 0
Cool! That's an answer for the shell, thank you. Now I'll just have to find out if Xfce's Thunar can do the same thing. About educating women... you know how good it feels to offer smooth solutions that do not require too much learning ;-)

I found out something interesting: You can do
Quote:
$ set -P
if you want cd and similar commands to change their behaviour in the described way in the current session.

If you want the change to be permanent, add
Quote:
set -P
to your ~/.bashrc

Source: http://linux.about.com/library/cmd/blcmdl1_cd.htm

Last edited by doncristobal; 02-01-2013 at 11:32 AM. Reason: added info about set -P
 
  


Reply

Tags
link



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
Windows symlink CrashedAgain Linux - Software 4 04-09-2008 09:49 PM
Symlink not recognized by Windows csapdani Linux - Networking 1 06-07-2007 05:42 PM
an analogy for my Windows partition's performance newbiesforever General 12 11-21-2006 02:28 AM
Another Windows-Linux Analogy (not cars) aysiu General 3 07-30-2005 09:21 PM

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

All times are GMT -5. The time now is 09:39 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
Open Source Consulting | Domain Registration