Jump to content


Parent vs root directory?


  • Please log in to reply
2 replies to this topic

#1 hampeh

hampeh

    Member

  • Members
  • PipPip
  • 107 posts
  • Gender:Male
  • Location:tranung kite la...mane lagi :)
  • Interests:download tutorial, notes sampai penuh harddisk...tapi belum tentu baca...haha

Posted 20 March 2009 - 01:00 AM

Hi all,

Based on my understanding, root folder is /
But how about parent folder?

According to

http://www.computerh...om/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

#2 TESLA.COIL

TESLA.COIL

    CCNA and Unix expert

  • Members
  • PipPipPipPip
  • 619 posts
  • Gender:Male

Posted 20 March 2009 - 01:44 AM

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, 20 March 2009 - 01:47 AM.

  • 0

#3 Lethe

Lethe

    Insanity's Crescendo

  • Global Moderators
  • PipPipPipPipPip
  • 2842 posts
  • Gender:Male
  • Location:...

Posted 20 March 2009 - 01:50 AM

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....nts/3307_32.JPG should help you out clarify the unix file system hierarchy :)

Cheer Lethe.

Edited by Lethe, 20 March 2009 - 01:51 AM.

  • 0





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users