Can I create a one way symlink?Copy symlink AND where it points to using rsyncIs it possible to notify/warn that current path isn't a valid symlink anymore?Hot to make diff check a symlink link itself?Read target of symlink and increment target by oneCreate symlink - overwrite if one existsSymlink fallbackWhat idempotent command can I use to make a symlink pointing to a directory?Create hard link if possible, else use symlinkHow to get the filename of a symlink destination in a shell script?

If password expiration is applied, should door-lock expiration be applied too?

How does Peano Postulates construct Natural numbers only?

Do I even like doing research?

Too many pull requests in backlog

Can a Way of the Open Hand monk's Open Hand Technique prevent Legendary Action reactions?

What can I do if one employer used offer letter from first company against me?

Origin of Aliens in 'A Quiet Place'?

Why should I invest so much in 401(k)?

Why do HK chefs use a white cloth to clutch wok?

How to conceal multiple characters without making text dance upon hovering?

What does "Massage with salt" mean in a recipe?

1-1 correspondence in Category Theory

Match blood types in C

Displaying a Sudoku Board

Exactly what color was the text on monochrome terminals with green-on-black and amber-on-black screens?

Does Mage Hand require line of sight to summon?

What is a polite way to clarify my gender in phone calls?

Good type of bike to get for commuting (thinking of road v touring)

Simulate reproduction in a population of oozes

In a world where Magic steam Engines exist what would keep people from making cars

Why 401k contribution as % of salary vs. fixed amount per pay check?

A New Math Operation?

Dollar cost averaging vs buy low/sell high

Back with another one-line wonder!



Can I create a one way symlink?


Copy symlink AND where it points to using rsyncIs it possible to notify/warn that current path isn't a valid symlink anymore?Hot to make diff check a symlink link itself?Read target of symlink and increment target by oneCreate symlink - overwrite if one existsSymlink fallbackWhat idempotent command can I use to make a symlink pointing to a directory?Create hard link if possible, else use symlinkHow to get the filename of a symlink destination in a shell script?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









7


















I want to create a one way symlink i.e. I can use it to go to the destination directory but I cannot go back.



Let's say there is a directory called D with two subdirectories S1 and S2. I want to create a link in S1 that points to S2 (let's say ls2 -> ../S2/). If I do cd ls2 and then cd .. then I want to go to D and not S1.



Is it possible?










share|improve this question






















  • 7





    All symlinks are unidirectional... The ability to go back depends on whether you remember from where you came. So shells do remembers, others don't. Many shells won't remember when you use cd -P to change directory.

    – AlexP
    Oct 16 at 13:17


















7


















I want to create a one way symlink i.e. I can use it to go to the destination directory but I cannot go back.



Let's say there is a directory called D with two subdirectories S1 and S2. I want to create a link in S1 that points to S2 (let's say ls2 -> ../S2/). If I do cd ls2 and then cd .. then I want to go to D and not S1.



Is it possible?










share|improve this question






















  • 7





    All symlinks are unidirectional... The ability to go back depends on whether you remember from where you came. So shells do remembers, others don't. Many shells won't remember when you use cd -P to change directory.

    – AlexP
    Oct 16 at 13:17














7













7









7


2






I want to create a one way symlink i.e. I can use it to go to the destination directory but I cannot go back.



Let's say there is a directory called D with two subdirectories S1 and S2. I want to create a link in S1 that points to S2 (let's say ls2 -> ../S2/). If I do cd ls2 and then cd .. then I want to go to D and not S1.



Is it possible?










share|improve this question
















I want to create a one way symlink i.e. I can use it to go to the destination directory but I cannot go back.



Let's say there is a directory called D with two subdirectories S1 and S2. I want to create a link in S1 that points to S2 (let's say ls2 -> ../S2/). If I do cd ls2 and then cd .. then I want to go to D and not S1.



Is it possible?







symlink cd-command cwd






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 16 at 13:27









Gilles 'SO- stop being evil'

590k143 gold badges1213 silver badges1721 bronze badges




590k143 gold badges1213 silver badges1721 bronze badges










asked Oct 16 at 13:16









WYSIWYGWYSIWYG

3033 silver badges8 bronze badges




3033 silver badges8 bronze badges










  • 7





    All symlinks are unidirectional... The ability to go back depends on whether you remember from where you came. So shells do remembers, others don't. Many shells won't remember when you use cd -P to change directory.

    – AlexP
    Oct 16 at 13:17













  • 7





    All symlinks are unidirectional... The ability to go back depends on whether you remember from where you came. So shells do remembers, others don't. Many shells won't remember when you use cd -P to change directory.

    – AlexP
    Oct 16 at 13:17








7




7





All symlinks are unidirectional... The ability to go back depends on whether you remember from where you came. So shells do remembers, others don't. Many shells won't remember when you use cd -P to change directory.

– AlexP
Oct 16 at 13:17






All symlinks are unidirectional... The ability to go back depends on whether you remember from where you came. So shells do remembers, others don't. Many shells won't remember when you use cd -P to change directory.

– AlexP
Oct 16 at 13:17











1 Answer
1






active

oldest

votes


















21



















All symbolic links are one-way. As far as the kernel is concerned, after going into /D/S1 and running chdir("ls2"), you're in /D/S2, so if you run chdir(".."), you end up in /D.



If you do this in a shell, after



cd /D/S1
cd ls2
cd ..


you end up in /D/S1. The reason is that the shell does its own tracking of the current directory, and it remembers symbolic links.



You can't disable this shell behavior on a link-by-link basis, but you can disable it when you run the cd command. After running cd ls2, the shell remembers the current directory as /D/S1/ls2:



$ pwd
/D/S1
$ cd ls2
$ pwd
/D/S1/ls2
$ cd ..
$ pwd
/D/S1


To instruct the shell to forget its symlink-aware current directory tracking, pass the -P option to cd. The pwd command also has a -P option.



$ pwd
/D/S1
$ cd ls2
$ pwd
/D/S1/ls2
$ pwd -P
/D/S2
$ cd -P ..
$ pwd
/D


You can also forget the logical tracking when you change into the symlink:



$ pwd
/D/S1
$ cd -P ls2
$ pwd
/D/S2
$ cd ..
$ pwd
/D





share|improve this answer


























  • A small additional question if it is fine. Is there a way to make the file browser (thunar) forget the symlink track?

    – WYSIWYG
    Oct 31 at 12:29











  • @WYSIWYG I have no idea. You should ask that separately in a question tagged thunar.

    – Gilles 'SO- stop being evil'
    Oct 31 at 12:54













Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);














draft saved

draft discarded
















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f547076%2fcan-i-create-a-one-way-symlink%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown


























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









21



















All symbolic links are one-way. As far as the kernel is concerned, after going into /D/S1 and running chdir("ls2"), you're in /D/S2, so if you run chdir(".."), you end up in /D.



If you do this in a shell, after



cd /D/S1
cd ls2
cd ..


you end up in /D/S1. The reason is that the shell does its own tracking of the current directory, and it remembers symbolic links.



You can't disable this shell behavior on a link-by-link basis, but you can disable it when you run the cd command. After running cd ls2, the shell remembers the current directory as /D/S1/ls2:



$ pwd
/D/S1
$ cd ls2
$ pwd
/D/S1/ls2
$ cd ..
$ pwd
/D/S1


To instruct the shell to forget its symlink-aware current directory tracking, pass the -P option to cd. The pwd command also has a -P option.



$ pwd
/D/S1
$ cd ls2
$ pwd
/D/S1/ls2
$ pwd -P
/D/S2
$ cd -P ..
$ pwd
/D


You can also forget the logical tracking when you change into the symlink:



$ pwd
/D/S1
$ cd -P ls2
$ pwd
/D/S2
$ cd ..
$ pwd
/D





share|improve this answer


























  • A small additional question if it is fine. Is there a way to make the file browser (thunar) forget the symlink track?

    – WYSIWYG
    Oct 31 at 12:29











  • @WYSIWYG I have no idea. You should ask that separately in a question tagged thunar.

    – Gilles 'SO- stop being evil'
    Oct 31 at 12:54
















21



















All symbolic links are one-way. As far as the kernel is concerned, after going into /D/S1 and running chdir("ls2"), you're in /D/S2, so if you run chdir(".."), you end up in /D.



If you do this in a shell, after



cd /D/S1
cd ls2
cd ..


you end up in /D/S1. The reason is that the shell does its own tracking of the current directory, and it remembers symbolic links.



You can't disable this shell behavior on a link-by-link basis, but you can disable it when you run the cd command. After running cd ls2, the shell remembers the current directory as /D/S1/ls2:



$ pwd
/D/S1
$ cd ls2
$ pwd
/D/S1/ls2
$ cd ..
$ pwd
/D/S1


To instruct the shell to forget its symlink-aware current directory tracking, pass the -P option to cd. The pwd command also has a -P option.



$ pwd
/D/S1
$ cd ls2
$ pwd
/D/S1/ls2
$ pwd -P
/D/S2
$ cd -P ..
$ pwd
/D


You can also forget the logical tracking when you change into the symlink:



$ pwd
/D/S1
$ cd -P ls2
$ pwd
/D/S2
$ cd ..
$ pwd
/D





share|improve this answer


























  • A small additional question if it is fine. Is there a way to make the file browser (thunar) forget the symlink track?

    – WYSIWYG
    Oct 31 at 12:29











  • @WYSIWYG I have no idea. You should ask that separately in a question tagged thunar.

    – Gilles 'SO- stop being evil'
    Oct 31 at 12:54














21















21











21









All symbolic links are one-way. As far as the kernel is concerned, after going into /D/S1 and running chdir("ls2"), you're in /D/S2, so if you run chdir(".."), you end up in /D.



If you do this in a shell, after



cd /D/S1
cd ls2
cd ..


you end up in /D/S1. The reason is that the shell does its own tracking of the current directory, and it remembers symbolic links.



You can't disable this shell behavior on a link-by-link basis, but you can disable it when you run the cd command. After running cd ls2, the shell remembers the current directory as /D/S1/ls2:



$ pwd
/D/S1
$ cd ls2
$ pwd
/D/S1/ls2
$ cd ..
$ pwd
/D/S1


To instruct the shell to forget its symlink-aware current directory tracking, pass the -P option to cd. The pwd command also has a -P option.



$ pwd
/D/S1
$ cd ls2
$ pwd
/D/S1/ls2
$ pwd -P
/D/S2
$ cd -P ..
$ pwd
/D


You can also forget the logical tracking when you change into the symlink:



$ pwd
/D/S1
$ cd -P ls2
$ pwd
/D/S2
$ cd ..
$ pwd
/D





share|improve this answer














All symbolic links are one-way. As far as the kernel is concerned, after going into /D/S1 and running chdir("ls2"), you're in /D/S2, so if you run chdir(".."), you end up in /D.



If you do this in a shell, after



cd /D/S1
cd ls2
cd ..


you end up in /D/S1. The reason is that the shell does its own tracking of the current directory, and it remembers symbolic links.



You can't disable this shell behavior on a link-by-link basis, but you can disable it when you run the cd command. After running cd ls2, the shell remembers the current directory as /D/S1/ls2:



$ pwd
/D/S1
$ cd ls2
$ pwd
/D/S1/ls2
$ cd ..
$ pwd
/D/S1


To instruct the shell to forget its symlink-aware current directory tracking, pass the -P option to cd. The pwd command also has a -P option.



$ pwd
/D/S1
$ cd ls2
$ pwd
/D/S1/ls2
$ pwd -P
/D/S2
$ cd -P ..
$ pwd
/D


You can also forget the logical tracking when you change into the symlink:



$ pwd
/D/S1
$ cd -P ls2
$ pwd
/D/S2
$ cd ..
$ pwd
/D






share|improve this answer













share|improve this answer




share|improve this answer










answered Oct 16 at 13:27









Gilles 'SO- stop being evil'Gilles 'SO- stop being evil'

590k143 gold badges1213 silver badges1721 bronze badges




590k143 gold badges1213 silver badges1721 bronze badges















  • A small additional question if it is fine. Is there a way to make the file browser (thunar) forget the symlink track?

    – WYSIWYG
    Oct 31 at 12:29











  • @WYSIWYG I have no idea. You should ask that separately in a question tagged thunar.

    – Gilles 'SO- stop being evil'
    Oct 31 at 12:54


















  • A small additional question if it is fine. Is there a way to make the file browser (thunar) forget the symlink track?

    – WYSIWYG
    Oct 31 at 12:29











  • @WYSIWYG I have no idea. You should ask that separately in a question tagged thunar.

    – Gilles 'SO- stop being evil'
    Oct 31 at 12:54

















A small additional question if it is fine. Is there a way to make the file browser (thunar) forget the symlink track?

– WYSIWYG
Oct 31 at 12:29





A small additional question if it is fine. Is there a way to make the file browser (thunar) forget the symlink track?

– WYSIWYG
Oct 31 at 12:29













@WYSIWYG I have no idea. You should ask that separately in a question tagged thunar.

– Gilles 'SO- stop being evil'
Oct 31 at 12:54






@WYSIWYG I have no idea. You should ask that separately in a question tagged thunar.

– Gilles 'SO- stop being evil'
Oct 31 at 12:54



















draft saved

draft discarded















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f547076%2fcan-i-create-a-one-way-symlink%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown









Popular posts from this blog

Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

Ласкавець круглолистий Зміст Опис | Поширення | Галерея | Примітки | Посилання | Навігаційне меню58171138361-22960890446Bupleurum rotundifoliumEuro+Med PlantbasePlants of the World Online — Kew ScienceGermplasm Resources Information Network (GRIN)Ласкавецькн. VI : Літери Ком — Левиправивши або дописавши її