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;
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
add a comment
|
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
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 usecd -P
to change directory.
– AlexP
Oct 16 at 13:17
add a comment
|
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
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
symlink cd-command cwd
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 usecd -P
to change directory.
– AlexP
Oct 16 at 13:17
add a comment
|
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 usecd -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
add a comment
|
1 Answer
1
active
oldest
votes
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
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
add a comment
|
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
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
add a comment
|
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
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
add a comment
|
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
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
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
add a comment
|
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
add a comment
|
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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