Operating System - HP-UX
1832645 Members
2561 Online
110043 Solutions
New Discussion

What is the purpose of . and .. in every directory?

 
Yap Yen Nee
Contributor

What is the purpose of . and .. in every directory?

Hi,

I noted that when you do a ls -l under a particular directory, you will get 2 funny directories which are . and .. . What is the purpose of these 2 files? HOw should be the permission be like?

Thank you.

regards
Yen Nee
6 REPLIES 6
Sanjay Kumar Suri
Honored Contributor

Re: What is the purpose of . and .. in every directory?

They are not funny.
. means the current directory.
.. means the parent directory.

One can use $cd .. to jump to the parent directory of the current directory.

sks
A rigid mind is very sure, but often wrong. A flexible mind is generally unsure, but often right.
Biswajit Tripathy
Honored Contributor

Re: What is the purpose of . and .. in every directory?

You are seeing . and .. in the output of "ls -l" ?
You surely mean "ls -al", don't you? :-)

As Sanjay already said, . is current and .. is the
previous directory unless your current directory
is '/', in which case . and .. point to the current
root directory.

- Biswajit
:-)
Ravi_8
Honored Contributor

Re: What is the purpose of . and .. in every directory?

Hi

. is current directory
.. is parent directory

these two will be hidden and craeted by defualt whenever you craete a directory
never give up
Sanjay Kumar Suri
Honored Contributor

Re: What is the purpose of . and .. in every directory?

Check this link for more inputs:

http://www.seas.upenn.edu/~cse120/resources/primers/unix/lesson5.shtml


sks
A rigid mind is very sure, but often wrong. A flexible mind is generally unsure, but often right.
Andrew Cowan
Honored Contributor

Re: What is the purpose of . and .. in every directory?

Put simply the "." and ".." entries are the links/path backs to the level above. They are shown individually like this so that you can see the ownerships and permissions of your current directory and its parent.
Trond Haugen
Honored Contributor

Re: What is the purpose of . and .. in every directory?

The permissions of course depends on which directory you are in.
The only way I know to check is to run 'swverify \*' which will then do a check of ALL system files.

Regards,
Trond
Regards,
Trond Haugen
LinkedIn