6

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/ ?

2 Answers 2

3

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
/
2
  • 2
    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. Commented Dec 27, 2012 at 21:16
  • Good point @BatchyX it's not exactly the same... I'll update my answer to reflect that. Commented Jan 8, 2013 at 22:21
3

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.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.