LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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


Reply
  Search this Thread
Old 09-14-2010, 04:08 AM   #1
Couling
Member
 
Registered: Oct 2007
Posts: 30

Rep: Reputation: 15
Where should I expect to get using ./symlink/../


Hi

I've got a question about the behaviour of symlinks after being supprised by the result of something i tried yesterday.

Example directory structure:
Code:
a
   link --> /b/b_child1
b
   b_child_1
   b_child_2
If my current working directroy was set to /a/link and then i use "cd .." then i will get to /a

I'd allways thought this was ubiquitous, but on my debian box, I found this to be the exception. So for example, it is possible to:
Code:
touch /a/link/../b_child_2/new_file
With the result that /b/b_child_2/new_file is created.


How wide spread is this behaviour?
That is will i expect to see the same thing only on Debian or on any Linux or across the whole of POSIX?

Thanks very much for your time.

Last edited by Couling; 09-14-2010 at 04:09 AM.
 
Old 09-14-2010, 09:08 PM   #2
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,321
Blog Entries: 28

Rep: Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141
Your examples are so abstract that I'm not sure I understand the question. Would you be kind enough to make them more concrete?

The best explanation I have so far found for symlinks is in the Slackbook:

http://www.slackbook.org/html/filesy...ure-links.html
 
Old 09-15-2010, 04:06 AM   #3
Couling
Member
 
Registered: Oct 2007
Posts: 30

Original Poster
Rep: Reputation: 15
Sorry for being unclear. Sadly the link you gave makes no reference to the use of .. with symbolic links (which is the cause of my confusion).

I'll try to demonstrate what I'm talking about with some actual commands:

Set up some directories
Code:
~ $ mkdir test_dir
~ $ cd test_dir/
~/test_dir $ mkdir a b b/c
~/test_dir $ ln -s ../b/c a/link
~/test_dir $ find .
.
./b
./b/c
./a
./a/link
Test 1 (This is how I previously thought links allways behaved)
Code:
~/test_dir $ cd a/link/..
~/test_dir/a $ touch file_1
~/test_dir/a $ cd ~/test_dir/
~/test_dir $ find .
.
./b
./b/c
./a
./a/file_1
./a/link
cd moved to ~/test_dir/a and the file was consiquently there.

Test 2 (Links usually act like this at least on my Debian box)
Code:
~/test_dir $ touch a/link/../file_2
~/test_dir $ find .
.
./b
./b/file_2
./b/c
./a
./a/file_1
./a/link
touch created the file in b not a.

It seems that cd is the exception, all other programs I test perform as in Test 2.

Before a couple of days ago i'd never seen this before and it has the potential to leave a few security holes open.

Is the result of Test 2 part of the POSIX standard or is it a linux specific thing?

Last edited by Couling; 09-15-2010 at 04:08 AM.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Expect script: how do i send function key F12 in an expect script alix123 Programming 4 09-01-2013 09:06 PM
[SOLVED] /usr/bin/expect : Script to check server load using both expect and bash Soji Antony Programming 1 07-27-2010 11:27 PM
expect: line seems to match exactly, however expect thinks not deadeyes Linux - General 5 06-16-2010 06:05 PM
Calling expect scripts from other expect scripts sevapopov Linux - Software 3 04-03-2008 09:33 PM
Symlink Mestax Linux - Newbie 3 09-04-2003 12:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:36 PM.

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