Unix Terminal Command ../../

Hi,

Can someone help me figure out what the definition of ls ../../ is? It's the only command I haven't been able to figure out or find online.

Thank you.
ls
is just a command to list directory contents. You can see more by typing
man ls


Directories are pretty much tree structured.



ls ../../


means list the contents inside previous two directories.


./           means current directory you're in
../          means previous directory
../../       means previous 2 directories, and so on
>> fiji885

I'm glad you were so thorough with your answer. I have to change some of my other incorrect definitions now.

Thank you.
Interesting how a Windows command prompt exhibits similar behavior with ./ and ../ as does *nix.

I remember roaming around with the same command(s) with MS-DOS.

Ah, good times, good times.
Interesting how a Windows command prompt exhibits similar behavior with ./ and ../ as does *nix.
I don't think that's a coincidence. DOS (and later windows) borrowed from UNIX in this respect.

But UNIX does it right in my opinion. When you create a directory (at the system call level) the directory automatically gets two entries:
. // This is a hard link to the current directory
.. // This is a hard link to the parent directory.

So there's no special code to use these directory entries, they simply EXIST. The only exception is the root directory, which has no .. entry.
But UNIX does it right in my opinion. When you create a directory (at the system call level) the directory automatically gets two entries:
. // This is a hard link to the current directory
.. // This is a hard link to the parent directory.

So there's no special code to use these directory entries, they simply EXIST. The only exception is the root directory, which has no .. entry.
I don't really understand the difference. "." and ".." are valid on any directory in Windows, as well (except on a drive's root, or the kernel's directory tree root).
I think the difference is that you could in UNIX create a different directory called '.' and make it point wherever you want. The UNIX directories are really just links without any special significance other than the fact that they are automatically created for you, whereas in Windows they are handled specially by the directory parser.

At least that's my understanding; maybe Windows also creates those as directories and handles them the same way, I haven't checked.
I think the difference is that you could in UNIX create a different directory called '.' and make it point wherever you want.
"You" as in "the user"? I seriously doubt that.
In both nix and Windows . and .. are special entries in the directory table managed by the OS file system kernel. You cannot modify them to point somewhere else without first doing some damage to the OS.
Well "you" as in root may be able to change the meaning of . with a tool like debugfs.
Last edited on
Well "you" as in root may be able to change the meaning of . with a tool like debugfs
That's an interesting idea! You're probably right, but I suspect it would put the system into a tailspin. Lots of progams probably assume that "." is the current directory. The filesystem check program fsck would almost certainly flag and correct this.
Topic archived. No new replies allowed.