Question_root@Arduino:~# and root@Arduino:/#

Hello Everyone.
After I login Arduino: The interface is appeared.
root@Arduino:~# . But when I type ls.
root@Arduino:~#

(Nothing to appear)
and then I type: cd /
and type ls.

root@Arduino:/# ls
bin dev etc lib lost+found mnt overlay proc rom root sbin sys tmp usr var www

Can any one explain to me about the different between ~#(default but nothing) and /#.
Thanks so much.

First off:

  • "~" is a shorthand notation for the current user's home directory
  • "/" is the notation for the file system's root folder

When you first log in, you are in the home directory for the root user. Since you log in as the user "root", the home directory is "/root" which is the "root" directory at the root of the file system. (Note that there are two different meanings for the word "root" in that last sentence, it's important to know that there is a difference - the home folder for the root user is not the same as the root folder of the file system.)

When the current directory is "~" you are looking at the root user's home directory . Unless you put something there yourself, it normally doesn't have any visible files, so you don't see anything when you use the "ls" command. But that's not to say that the directory is empty, as evidenced if you use the "ls -a" command to show all files in the current directory:

root@Yun2:~# ls -a
.       ..      .cache  .gnupg
root@Yun2:~#

When you use the "cd /" command, you are changing directories to the root directory of the file system. Issuing the "ls" command now shows you the contents of that root directory. Note that one of the items in that directory is "root" which is the root user's home directory. If you now change to that directory, you will notice that the current path in the command prompt changes back to "~" because the system recognizes that you are back in your home directory.