1

When I use su to get root, and then I cd ~

I am not on the /root, when I ls it shows me a Desktop file and some hidden files like .bashrc, but nothing else.

root@debian:~# ls -a . .. .adobe .bash_history .bashrc .cache .config Desktop .gnome2 .gnome2_private .local .macromedia .mozilla .profile .vim .viminfo 

to go to the real /root I have to cd / from here.

I thought that there were no ../ from /root, so what is this ~ ?

edit 2 :

xxxx@debian:~$ ls Desktop Documents Downloads Music Pictures Public Templates Videos xxxx@debian:~$ su Password: root@debian:/home/xxxx# cd root@debian:~# ls Desktop root@debian:~# pwd /root root@debian:~# cd / root@debian:/# ls bin boot dev etc home initrd.img lib lib64 lost+found media mnt opt proc root run sbin srv sys tmp usr var vmlinuz root@debian:/# pwd / 
2
  • 1
    The / directory is not the same as /root. Commented Dec 20, 2015 at 18:06
  • after typing su what is the result of pwd command ? Commented Dec 20, 2015 at 18:12

4 Answers 4

4

You are mistaking two things that have similar names.

root - is also called / - it's the starting point of your disc. If you imagine your filesystem laid out as a tree(in mathematical sense), you will see clearly why it's called a root - it does not have an ancestor, only children.

However, /root is whole different thing. You can see the name differs - very little, only / at the beginning, but that's what changes meaning dramatically. /root is a directory called root which you can find in /. So, if you do:

cd / && ls | grep root

you will see that there is ineed a directory called root. And that's the directory you're mistaking for /. The difference is that /root is home directory for root user, and / is a root of your filesystem. You can read more about this topic on this site

2

The directory /root is a directory called root at the top of the filesystem. Perhaps you are confusing the root of the filesystem / with the home directory for the root user.

3
  • so /root is not the directory containing bin,boot,dev etc... but , / is (according to my new edit )? Commented Dec 20, 2015 at 18:22
  • yes that's is /root is just the homedir of the user root Commented Dec 20, 2015 at 18:46
  • @aqww the directory /root is no different to a hypothetical directory /admin Commented Dec 20, 2015 at 23:25
1

Normal. su without argument is just changing the id of the user without really loading the full requested user environment.

So basically you are just in your local user environment under root id.

If you want to really load root environment you have to do su - or su -l which will load the requested user full environment.

2
  • 1
    and im not sure why this answer got downvoted as far as im pretty sure the OP just typed su instead of su - or su -l which keeps the standard user configuration instead of fully loading the root environment. And im also pretty sure that the /root directory doesn't contains any Desktop directory...nor .Adobe hidden directory (99% of chance it's his standard user homedir) Commented Dec 20, 2015 at 18:10
  • well it seems im wrong. Just checked in my shell, just typingsu keep you in my local user directory, but $HOME is defined to /root, so typing cd ~ drives me to /root Commented Dec 20, 2015 at 18:44
1

To know where you are in the directory tree, you have to type:

pwd 

By the way, the root directory is /root. this is the personal directory of the root user (the superadmin if you prefer). When you type:

cd / 

You are relocating your actual user at the root (the top) of the filesystem hierarchy which contains the root user directory.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.