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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
11-18-2004, 05:23 AM
|
#1
|
|
Senior Member
Registered: Jul 2004
Location: Germany
Distribution: open SUSE 11.0, Fedora 7 and Mandriva 2007
Posts: 1,638
Rep:
|
Absolute and relative paths
Could you explain me the difference between absolute path and relative path?
/export/home/heden/rhost
The above is said to be absolute path.
Is it because the forward slash?
In Windows, we talked about a single path. There are no two paths in Windows.
What are those absolute and relative paths?
|
|
|
|
11-18-2004, 05:41 AM
|
#2
|
|
Senior Member
Registered: Nov 2003
Location: West Sussex, England
Distribution: Gentoo
Posts: 1,457
Rep:
|
Quote:
|
Is it because the forward slash?
|
Pretty much - by putting that / at the start, you're saying "Start at the root directory, and work along"
If you don't put the / at the front, you're saying "Start from the current directory"
If you put ../ at the front, you're saying "Go back one directory and then start looking"
And if you put ~/ at the front, you're saying "Look in my home directory"
So, to sum up, let's say you're in the directory /etc/wibble
If you say cd /foo/bar you're asking to go to the directory /foo/bar
If you say cd foo/bar you're asking to go to the directory /etc/wibble/foo/bar
If you say cd ../foo/bar you're asking to go to the directory /etc/foo/bar
And if you say cd ~/foo/bar you're asking to go to the directory /home/yourname/wibble/foo/bar
Last edited by oneandoneis2; 11-18-2004 at 05:43 AM.
|
|
|
|
11-18-2004, 05:57 AM
|
#3
|
|
Senior Member
Registered: Jul 2004
Location: Germany
Distribution: open SUSE 11.0, Fedora 7 and Mandriva 2007
Posts: 1,638
Original Poster
Rep:
|
Thanks for the answer.
So the following is an abslote path.
/export/home/heden/rhost
If I take the forward slashes away, it becomes a relative path.
export home heden rhost
Please tell me if I am wrong. However, without slashes, it looks strange.
You have beautifully explained the meanings of / , ../ and ~/ . I just want to know the meaning of the ./
You said / this means start at the root directory as well as the current directory. Was it a mistake? Shouldn't it be ./
Please reply me when possible. I appreciate very much your explainations.
|
|
|
|
11-18-2004, 07:35 AM
|
#4
|
|
Senior Member
Registered: Nov 2003
Location: West Sussex, England
Distribution: Gentoo
Posts: 1,457
Rep:
|
Quote:
If I take the forward slashes away, it becomes a relative path.
export home heden rhost
Please tell me if I am wrong. However, without slashes, it looks strange.
|
No, it's only the first / that you take away.
export /home/heden/rhost is absolute
export home/heden/rhost is relative to the current working directory
Quote:
|
I just want to know the meaning of the ./
|
./ refers to the current directory
/ = root directory
./ = current directory
../ = parent directory
You often don't have to bother with ./ - if you're in /foo and you want to switch to /foo/bar, you can use either:
cd /foo/bar
cd ./bar
or just
cd bar - so naturally this is the one you'd usually use
When the ./ DOES become useful is for things like moving files to the current directory, eg mv /foo/bar/* ./
Last edited by oneandoneis2; 11-18-2004 at 07:39 AM.
|
|
|
|
11-08-2008, 05:57 PM
|
#5
|
|
LQ Newbie
Registered: Nov 2008
Location: FT. Bragg, NC
Distribution: Red Hat Enterprise Linux v5
Posts: 2
Rep:
|
Noobs 1st Post...
Ok hello all,(first post)
I am a noob to Linux but not to computers. I work for a College Network MIS department and I am taking a Red Hat Academy course for familiarization. I have several windows and Cisco networks certifications but, Linux is a new animal to me. I have the following question from one of my assignments for which I am becoming greatly confused.
The chapter is on linkings. Hard/soft I can complete the #6 question below but I can not seem to make the command for the relative linking(#7) below work. I grade the task and it gives me partial credit for the command but it says that my link does not resolve to ../../usr/share/doc (home/student/usr/share/doc)
6.Create a soft link to the /usr/share/doc directory, called docabs, using an absolute reference.
[######4625@localhost ~]$ ln -s usr/share/doc ~/docabs (This worked)
7.Create a soft link to the ../../usr/share/doc directory, called docrel, using a relative reference. (Note: depending on the location of your home directory, you may need to add or remove some .. references from the proceeding filename. Include enough so that the the soft link is a true relative reference to the /usr/share/doc directory.
Below are three commands that I have tried that produce output but it wont pass the grade script that checks the exercise. I am not missing much I am sure I am close probably more with the second command than the first but it still is incorrect. I know this will be something simple or something I am just overlooking but its vexing me terribly. Any help would be appreciated. I hate to trouble you folks with such trivial stuff but I am a "noob" so I wont ever learn if I don't ask.
[######4625@localhost ~]$ ln -s usr/share/doc ../######4625/docrel
[######4625@localhost ~]$ ln -s usr/share/doc ../../docrel
[######4625@localhost ~]$ ln -s /../../usr/share/doc docrel
{Content from Academy site.}
If you have finished the exercise correctly, you should be able to reproduce output similar to the following.
[student@station student]$ ls -l
total 12
.......content removed........
lrwxrwxrwx 1 student student 14 Jul 21 10:03 docabs -> /usr/share/doc
lrwxrwxrwx 1 student student 19 Jul 21 10:03 docrel -> ../../usr/share/doc
Thanks so much for your time.
Gatorbug
|
|
|
|
11-08-2008, 06:18 PM
|
#6
|
|
Senior Member
Registered: Sep 2003
Posts: 3,171
Rep: 
|
You should start a new thread rather than resurrect a 4 year old thread.
Quote:
6.Create a soft link to the /usr/share/doc directory, called docabs, using an absolute reference.
[######4625@localhost ~]$ ln -s usr/share/doc ~/docabs (This worked)
|
This should not have worked because, as written, you have used a relative reference to the directory you are linking to. Do you see where?
Quote:
Below are three commands that I have tried that produce output but it wont pass the grade script that checks the exercise. I am not missing much I am sure I am close probably more with the second command than the first but it still is incorrect. I know this will be something simple or something I am just overlooking but its vexing me terribly. Any help would be appreciated. I hate to trouble you folks with such trivial stuff but I am a "noob" so I wont ever learn if I don't ask.
[######4625@localhost ~]$ ln -s usr/share/doc ../######4625/docrel
[######4625@localhost ~]$ ln -s usr/share/doc ../../docrel
[######4625@localhost ~]$ ln -s /../../usr/share/doc docrel
|
/ means start at root of filesystem (absolute reference).
./ means current directory
../ means go up one directory from the current directory then proceed.
../../ means go up two directories then proceed.
../../../ means go up three directories then proceed.
And so forth.
|
|
|
|
11-08-2008, 08:48 PM
|
#7
|
|
LQ Newbie
Registered: Nov 2008
Location: FT. Bragg, NC
Distribution: Red Hat Enterprise Linux v5
Posts: 2
Rep:
|
Quote:
Originally Posted by jiml8
You should start a new thread rather than resurrect a 4 year old thread.
This should not have worked because, as written, you have used a relative reference to the directory you are linking to. Do you see where?
/ means start at root of filesystem (absolute reference).
./ means current directory
../ means go up one directory from the current directory then proceed.
../../ means go up two directories then proceed.
../../../ means go up three directories then proceed.
And so forth.
|
Sorry for posting here... but The thread was not closed and it fit the problem that I had. So I posted here to keep from creating duplicate threads in your forum. I didn't check the date on the thread when I posted.
The above command that You said should not have worked.(due to a relative reference)was correct.
[######4625@localhost ~]$ ln -s /usr/share/doc ~/docabs (This worked)
I just pasted it poorly... I left off the / at the beginning. I had not noticed that I left it off. Devils in the details.
Second, Without knowing it you also solved my problem. Thank you.
The command should have been:
[######4625@localhost ~]$ ln -s ../../usr/share/doc docrel
(This worked)You pointing out my error in this post fixed my problem.
I wont tag this forum again... You probably ought to close it then. As it still searchable and open to replies.
Thanks again,
Gatorbug
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 07:15 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|