Parent vs root directory?
Posted 20 March 2009 - 01:00 AM
Based on my understanding, root folder is /
But how about parent folder?
ls / is List the contents of your root directory.
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
Posted 20 March 2009 - 01:44 AM
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.
. means present directory
.. means parent directory
If am in /home/jax directory and if i do
[root@client1 jax]# ls -l ..
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 .
-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.
Posted 20 March 2009 - 01:50 AM
/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
Edited by Lethe, 20 March 2009 - 01:51 AM.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users