If you type cd or cd, you should be taken to your home directory, but instead you’re taken to the /root directory. Whenever you log in as the root user on Linux, if you’re encountering this error, you’ll get a lot of warning messages. Since it isn’t an error to begin with, fixing it is a breeze.
Instead, This is Due To A Quirk in Linux’s Home Directory Allocation System.
Despite being a common occurrence, this type of behaviour can be very perplexing to those who have never experienced it before. No matter where you are in Linux’s directory structure, you can always return to your home directory by entering the commands cd or cd into the terminal.
This holds true regardless of whether your working with internal or external files. If you become lost while working your way up the directory tree, you may easily get back to the point where you began by opening the terminal and typing cd.
Although the root user’s home directory may be located at /home/root on some Linux variants, it is more commonly found at the very root of the file system, at the directory named /root.
While this can be changed, in practise this is how the vast majority of Linux distributions operate. At the command prompt, while logged in as a regular user, try entering cd /root. The command “bash: cd /root: Permission refused” will appear since you are not the root user.
Now type gksu x-terminal-emulator at the terminal to launch a graphical root terminal window. Since this launches a fully elevated command prompt, you’ll be prompted to enter your administrative password.
The root user’s name is hashed out in many Linux versions (especially those based on Ubuntu) so that nobody may log in as them. If you’re using Ubuntu or a distribution with a similar error message, you can still log in as root with this command and not worry about the hash system.
However, this will launch a new terminal window rather than replacing the one you’re already in. Once you get the bash prompt, hit enter after typing whoami; cd; pwd. The user’s identity is determined, and then the working directory is switched to the user’s home directory.
Now that you’re logged in as root, you’ll see that your home directory isn’t /home/root but rather /root. This is done by Linux distributions because some users want to have their /home directory located on a drive other than the one that contains the root file system (/).
Since You Are Still The Root User in This Window, You Must Type The Exit Command To Close it When You Are Through.
Having /root stored elsewhere ensures that you can still boot the system as superuser if the disc containing your /home directory fails for whatever reason. For the most part, distributions allow all normal users’ home folders to be accessible by all other users.
Each of them has Unix permissions of 755. With 700 permissions, only the root super user can ever view the contents of the /root directory. As long as you obtained the same or similar results as above, you’re good to go.
The tilde () is just a placeholder that the shell uses to represent the user’s home directory regardless of where it is. In some contexts, you may encounter the term “tilde,” which is the literal name for this sign.