Posted on 2011-04-19
Last Modified: 2012-06-22
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

Question by:nobleit
    LVL 7

    Expert Comment

    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 :)

    Author Comment

    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..
    LVL 31

    Expert Comment

    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
    LVL 38

    Accepted Solution

    > 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
    LVL 76

    Expert Comment

    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.
    LVL 13

    Expert Comment

    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 ~.

    Author Comment

    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

    LVL 38

    Expert Comment

    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).
    LVL 16

    Expert Comment

    Check /etc/passwd file, those have been defined in it by default, but could be changed by a system administrator.
    LVL 13

    Assisted Solution

    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

    LVL 1

    Expert Comment

    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 improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
    The purpose of this article is to demonstrate how we can use conditional statements using Python.
    Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now