Linux / Folder and /root folder

/ (Root directory) vs /root directory

  1. / directory called as Root Directory sits on the top of the file system hierarchy.
    • That means it is the ultimate parent or grandparent or grand grandparent of any file or directory you can find on your system.
    • It contains all the files necessary for the system to work such as boot files, libraries, packages, essential binaries, system configuration, user files and temporary files.

Linux file system source

  1. Now /root is the Home directory for User named Root. See at the bottom right in above image.

    • Just like every User has it's own directory with his/her username under /home, User Root must have also a directory.
    • But Since Root user needs to know every tiny detail about system, so his home directory is created under / itself by the name /root
    • It contains the files and folders you created when you were root user and also the hidden configuration files for some applications or packages you installed.

Now when I sudo cd root/ I stay in the same folder (/)

As pointed by cylglad in the comments,

cd is a builtin shell command, so doing sudo cd /root won't work

See this :

amit@C0deDaedalus:~$ cd /root
bash: cd: /root: Permission denied
amit@C0deDaedalus:~$ 
amit@C0deDaedalus:~$ sudo cd /root
[sudo] password for amit: 
sudo: cd: command not found

Instead you have to first change to root user, then do a cd to /root

$ sudo -i
# cd /root
# pwd

Feel free to add in more details.

Tags:

Linux

Centos

Root