Link to home
Start Free TrialLog in
Avatar of nobleit
nobleit

asked on

root_home

Could any expert help me to differentiate home and root in linux

In my case where I am standing is home or root..
mathew@mathew-Inspiron-1501:~$ pwd
/home/mathew
mathew@mathew-Inspiron-1501:~$

Avatar of saastech
saastech
Flag of United States of America image

home folder is a home folder of the user who is logged into the system; for example, you are logged into as mathew.

when you login as user "root" that is the user with all admin privileges to your linux computer. Normally, you dont login with root b/c it has so many rights. But rather run "su" to run commands from another user login.

Hope this kinda helps :)
Avatar of nobleit
nobleit

ASKER

mathew@mathew-Inspiron-1501:~$ pwd
/home/mathew
mathew@mathew-Inspiron-1501:~$


In this situation - I just went to terminal
1) this is root or home
2)from here what is command to go to root..
please..
Avatar of farzanj
Root is a user -- administrator user in Linux/Unix

Root also has a home

You also have a home.

Root home is ~root
Your home is ~mathew

You can say echo ~root

This will show you home of root user

And
echo ~mathew

will show you your home directory
ASKER CERTIFIED SOLUTION
Avatar of wesly_chen
wesly_chen
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
wesly_chen has put it nicely.  Root is the beginning of things so for the file system that is / and the first user is root (uid 0) whose home direcotry is /root.
The ~ in your prompt means your home directory.  That's to save space in your prompt; bash expects you to realize that it's short for /home/mathew.  If you do
"cd /" to change to root your prompt will say / instead of ~.
Avatar of nobleit

ASKER

There are the outputs I get
please check experts these are the expected one..

root@mathew-Inspiron-1501:~# cd /
root@mathew-Inspiron-1501:/# pwd
/
root@mathew-Inspiron-1501:/# ls
bin    etc             lib         opt   selinux  u01      vmlinuz.old
boot   home            lost+found  proc  srv      usr
cdrom  initrd.img      media       root  sys      var
dev    initrd.img.old  mnt         sbin  tmp      vmlinuz
root@mathew-Inspiron-1501:/# sudo su -
root@mathew-Inspiron-1501:~# pwd
/root
root@mathew-Inspiron-1501:~# cd /home
root@mathew-Inspiron-1501:/home# ls
mathew  oracle



Can I make sure this is the root?

mathew@mathew-Inspiron-1501:/$ pwd
/

The root directory is only one, / , for all the Unix/Linux machine.
Your "root" home directory is /root.

If you know what do you mean about "root", then you got what you have.

As my humble guess, you probably ask for "/" as root and /home/mathew as your home (dir).
Check /etc/passwd file, those have been defined in it by default, but could be changed by a system administrator.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Perhaps you are being confused by the fact that there are two things in linux which are named root.

The first is a directory.  It is the base directory of the entire file system, written as a single slash (/).  It is often called the "root" directory of the file system.  It contains both files and directories.  It's distinguishing characteristic is that it does not have a parent directory.

The second thing named root is a userid.  It is the administrative user of the system, and has a uid of zero and a gid of zero.  it is also referred to as the superuser since it has complete access to all parts of the system.

Now that we have defined the two things which can be root, we need to look at the concept of "home" directory.  Every user on the system has a "home" directory.  It is defined in the file /etc/passwd for every user.  Home directories can be located anywhere in the file system.  By convention most user's home directory is in the directory /home.  This, however is not always true.  For example, on my system, the home directory for the user "apache" is "/var/www".  

In the early days of unix, the home directory for the "root" user was actually the root directory for the entire system, "/".  In more modern systems, and in most linux systems, this directory is now "/root". I believe this is to make it more difficult for you to inadvertently do something which could damage your system.

I hope this helps clear things up.