Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am receiving an error from an application I am running.

The error looks like this:

john@john-replacement:~/Desktop/yarbu-1.4.8/bin$ sudo yarbu-engine --VERBOSE
/usr/local/bin/yarbu-engine: line 996: cd: /usr/local/bin/../../etc/yarbu/conf/default: No such file or directory

What do the dots mean in /usr/local/bin/../../etc/ ?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

The ../ is notation for "the parent directory" so, in the case you presented:

/usr/local/bin/../../etc/yarbu/conf/default

The system will resolve that as:

/usr/etc/yarbu/conf/default

It's the same as if you were in the directory /usr/local/bin and you then typed cd .. twice, you would now be in the /usr directory.

You can verify this yourself:

$ cd /usr/local/bin
$ pwd
/usr/local/bin
$ cd /usr/local/bin/../../../
$ pwd
/
share|improve this answer
1  
It's not the same as cd .., which sanitizes the path using realpath. If one of the path components of /usr/local/bin is a symbolic link which points somewhere else, then realpath sanitization will not point to the same directory. e.g. if /usr/local is a synlink to /opt/unspecified, /usr/local/bin/../../etc/yarbu/conf/default is resolved as /opt/etc/yarbu/conf/default, but realpath sanitizes it as /usr/etc/yarbu/conf/default. Just nitpicking here. In contrast, ls ../../etc/yarbu/conf/default while in /usr/local/bin works. –  BatchyX Dec 27 '12 at 21:16
    
Good point @BatchyX it's not exactly the same... I'll update my answer to reflect that. –  gabe. Jan 8 '13 at 22:21
add comment

In addition to gabe's answer, which is nice:

The unix command readlink will always return the real path of a file or directory: readlink -f /usr/local/bin/../../etc/ will return /usr/etc/.

The command also resolves symbolic links. For example on my system, readlink -f /usr/bin/java returns /usr/lib/jvm/jdk-7.15-oracle-x64/jre/bin/java. Both use cases are very helpful for scripts.

Btw: .. (and also . which refers to the directory where you are) are not unix specific. The same will also work under at least all dos/windows, mac, linux/unix/bsd based operating systems.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.