What is the difference between / and /root in Linux?
/ is the root of the whole file system tree, the parent of every other directory. /root is simply the home directory of the user named root, the administrator account. The two are unrelated except by name.
Explain it simply
Two things are both called root, which confuses beginners. Picture a big tree: the trunk where everything starts is /. Now picture a flat in a society: the committee chairman's flat is /root. The chairman happens to be called "root" too.
/ is the top of the directory tree. Every path starts there: /etc, /home, /var. Even other disks are mounted somewhere beneath it.
/root is the home directory of the superuser account, like /home/amit is for the user amit. It is kept outside /home so root can still log in when /home is on a separate disk that failed to mount. Its permissions are 700, so ordinary users cannot read it.
Example
cd /
pwd
# /
sudo ls -ld /root
# drwx------ 5 root root 4096 ... /root
echo ~root
# /rootWhat to say in the interview
"/ is the top of the whole directory tree. /root is only the home folder of the root user. The root user's home is outside /home so the administrator can still log in if /home is on another partition that fails to mount."
Common mistakes
- Using root account and /root interchangeably in answers.