Linux / Folder and /root folder

I searched now a while but couldn't find an answer to this question.

I have a Linux based server (centOs).

In the root folder (/) i have a folder called root (/root).

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

First I thought that /root is a symlink but symlinks are cian blue and here I have dark blue.

I've read that the /root folder is the root user folder but I don't get in it.

Can somebody please explain what is going on here?

3

3 Answers

/ (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.

0

change to the root user and then CD to it

$ sudo su # cd /root 

as was previously mentioned, cd is a bash built-in and can't be executed using sudo. if you want to see the permissions on a directory, try

$ ls -al 

then look at the permission column to determine if the user you are logged in with has permissions.

3

Your root folder is /. Your /root is the root's home folder. For instance if you create a user called test, then it's home folder is /home/test. For root user, it is simply /root instead of /home/root.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like