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? |
Quote:
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 |
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. |
Quote:
export /home/heden/rhost is absolute export home/heden/rhost is relative to the current working directory Quote:
/ = 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/* ./ |
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 |
You should start a new thread rather than resurrect a 4 year old thread.
Quote:
Quote:
./ 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. |
Quote:
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 |
All times are GMT -5. The time now is 03:07 PM. |