[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 381
  • Last Modified:


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

  • 2
  • 2
  • 2
  • +5
2 Solutions
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 :)
nobleitAuthor Commented:
mathew@mathew-Inspiron-1501:~$ pwd

In this situation - I just went to terminal
1) this is root or home
2)from here what is command to go to root..
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

echo ~mathew

will show you your home directory
Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

> In this situation - I just went to terminal
> 1) this is root or home
It is your home directory, by default.

To go to "root", there are two meanings.
1. root directory , /
  how to get there?
  $ cd /

2. home directory of account "root".
  $ sudo su -
  # pwd
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 ~.
nobleitAuthor Commented:
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@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).
Joseph GanSystem AdminCommented:
Check /etc/passwd file, those have been defined in it by default, but could be changed by a system administrator.
I attached and tried to comment your post to explain it better.

/ and /home are absolute paths; it doesn't matter who you're logged in as.
/ is called "root".
"Root" also means the administrator user, which is an unrelated meaning.  The admin user's home directory used to be / in old enough versions of Unix, which is why the administrator is called "root", but that convention went out of style and nowadays root's home directory is typically "/root", not to be confused with "/" which is called "the root directory".  So for historical reasons the terminology is really confused.
root@mathew-Inspiron-1501:~# cd /          -- change to root dir.
root@mathew-Inspiron-1501:/# pwd           -- the prompt agrees
/                                          -- pwd agrees
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 -    -- su cmd will change to
root@mathew-Inspiron-1501:~# pwd          ... root's home dir
/root                                     ... which is /root
root@mathew-Inspiron-1501:~# cd /home     -- /home is an absolute path
root@mathew-Inspiron-1501:/home# ls       ... not dependent on which user
mathew  oracle                            -- these are your users

Open in new window

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.

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 2
  • 2
  • 2
  • +5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now