Sign in to follow this  
Followers 0
hampeh

Parent vs root directory?

3 posts in this topic

Hi all,

 

Based on my understanding, root folder is /

But how about parent folder?

 

According to

 

http://www.computerhope.com/unix/uls.htm

 

ls / is List the contents of your root directory.

 

while

 

ls ../ is List the contents of the parent directory.

 

However, I don't see any different on both commands..Would appreciate if someone could explain it..thanks

0

Share this post


Link to post
Share on other sites

ls / will list the contents of the root directory , here root is the directory not the super-user or admin root.

 

 

 

ls -l / will long list the contents of the directory / which contains directories like dev,usr,bin,sbin,home,root

 

ls -l /root will long list the contents of the directory root which is home directory of the administrator

 

 

/ is the top most directory, its the the starting point of any directory,hence it doens't have a parent directory.

 

Now

 

. means present directory

 

.. means parent directory

 

 

 

If am in /home/jax directory and if i do

 

[root@client1 jax]# ls -l ..

total 12

drwx------ 26 jax jax 4096 2009-03-20 02:41 jax

drwx------ 4 tesla tesla 4096 2009-03-16 05:29 tesla

drwx------ 5 tom tom 4096 2009-03-16 06:28 tom

 

 

It will list the contents of the parent directory of jax,which is /home.

 

 

NOw, if i do ls -l .

 

 

[root@client1 jax]# ls -l .

total 32

-rw-r--r-- 1 root root 0 2009-03-17 10:12 1

drwxr-xr-x 2 jax jax 4096 2009-03-18 13:08 Desktop

drwxr-xr-x 2 jax jax 4096 2009-03-12 09:50 Documents

drwxr-xr-x 2 jax jax 4096 2009-03-12 09:50 Download

drwxr-xr-x 2 jax jax 4096 2009-03-12 09:50 Music

drwxr-xr-x 2 jax jax 4096 2009-03-12 09:50 Pictures

drwxr-xr-x 2 jax jax 4096 2009-03-12 09:50 Public

drwxr-xr-x 2 jax jax 4096 2009-03-12 09:50 Templates

drwxr-xr-x 2 jax jax 4096 2009-03-12 09:50 Videos

 

 

 

Now to your question :

 

If your location is / and if you do ls -l / it will show u the contents of the directory / ,and if you do ls -l ../ it will still show the same output since there is no parent directory of / (root).

Edited by TESLA.COIL
0

Share this post


Link to post
Share on other sites

You see in linux/unix / is the root directory aka the root of the filesystem itself, as you correctly pointed out, using the double dot ".." simply tells your shell to look in the directory immediatly above the one you're in. Put you in the sadikhov directory its full path would be at least something like this :

 

/sadikhov/ where the first / represents the root directory itself

 

Ok now suppose you want to list all files/folders into the root directory (/) you have two choices

 

1 - change to the root directory itself with cd / and then issue an ls command

 

2 - while in the /sadikhov/ directory issue the command ls ../ this will tell your shell to list all the files and folders in the directory immediatly above which is / (root)

 

Don't get confused as the slash symbol (/) is used both to represent the root directory and as a separator. This http://www.students.ucs.ed.ac.uk/helpdesk/images/documents/3307_32.JPG should help you out clarify the unix file system hierarchy :)

 

Cheer Lethe.

Edited by Lethe
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0