Unix Terminal Command ../../

Sep 2, 2019 at 7:18pm
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.
Sep 2, 2019 at 7:22pm
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
Sep 2, 2019 at 7:29pm
>> fiji885

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

Thank you.
Sep 2, 2019 at 7:38pm
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.
Sep 3, 2019 at 8:49pm
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.
Sep 3, 2019 at 9:39pm
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).
Sep 4, 2019 at 4:47pm
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.
Sep 4, 2019 at 5:48pm
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.
Sep 4, 2019 at 6:30pm
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.
Sep 4, 2019 at 6:32pm
Well "you" as in root may be able to change the meaning of . with a tool like debugfs.
Last edited on Sep 5, 2019 at 3:46am
Sep 5, 2019 at 1:38am
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.