10

This question already has an answer here:

I have created 100 GB for /. When I opened Nautilus I have found the root folder. So what is difference between / and /root?

My username is enigma, and I have a folder named enigma in the /home folder and another folder with the same name in /media. What is the difference between these two folders and when do I have to use the second folder?

marked as duplicate by kos, Videonauth, muru, Jacob Vlijm, Eric Carvalho May 16 '16 at 23:41

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Marked as duplicate, but without indicating what it's a duplicate of. Please indicate. – Mathieu K. May 17 '16 at 2:55
9

If you're coming to the Linux world (taking Ubuntu flavour as your choice or other one) from the Microsoft Windows world, then these folder structures might seem very confusing.

To answer your question, let me give a very brief introduction to the Linux filesystem. In a Linux filesystem every possible and accessible files, folders are created under the "root" filesystem and in Linux system it's denoted as "/" symbol (unlike Windows, where different Drives are created, named C:, D: etc. and you can create and store your files and folders inside those drives). In Windows, the OS is most of the time installed in C: drive. In Linux, everything comes under / (aka "root" directory). When you install the Ubuntu OS, you'll notice that, several existing folders are already there inside /. Open nautilus and click "File system" (or in some new version "Computer" under Devices) in the left sidebar. This is actually what is inside /. Among those folders there are two named "root" and "home".

Now, In every Linux system, there is a root user who has all the power to change anything inside the OS (the super-admin ;), as I like to call it). You can create other users too. Whenever a new user is created, they'll have there own personal folder inside /home, e.g. /home/enigma (equivalent to C:\users\enigma in Windows). root user is the special one, who has one for his/her own directly under /, e.g. /root. Any user's personal directory is exclusively accessible to only that user (not technically only that user as root user can go & check & change anywhere). The other one with the same name as the User's name under /media is for mounting (beyond the scope of this discussion for mount, sorry, have to learn separately) storage devices like external HDD, Pendrive, CD/DVD etc. Modern Ubuntu handles them nicely and give a shortcut to those devices on the desktop. But, if you want to access those files through the terminal (command line), then you have to traverse like

cd /media/enigma/ <your device name>/<folder/file name>
  • U have given me a very good explanation. Thank you for that. Where I could find the installed application's files. Because just two days before I have installed gcc compiler. So where I could find their installed files and where should I save the programs which I have created. Can I save it in the /home directory? – BabyboB May 17 '16 at 15:45
  • You're welcome. In Linux, software installation is much more centralized manner, I.e. most of the time, you don't get to choose the folder, you want to install your app. The system decided it for you. The easiest way find the installed files (assuming, you've installed from Ubuntu package manager aka "apt" system) is to open Synaptic package manager from Menu > Admin (or just type in the Unity home page searchbox). – Tamal Patra May 18 '16 at 14:33
  • Then Search it (e.g. gcc), right-click on the app, click Properties. The popup, that opens, contains a tab Installed files. There you can locate all the files installed in that package. The binary gcc executable file is most probably installed in the /usr/bin or /bin folder. You should create your own files inside your home folder as being a general user, you might not have access to other folders in the system. My system is dual boor with Windows & I have C:, D: drives mounted within Ubuntu. I personally prefer to store my files there, so that I can access them through Windows, too. – Tamal Patra May 18 '16 at 14:35
34

In a nutshell:

  • / is called the root directory, for the whole system; all directories of the system descend from this directory one way or another.

  • /root is the root user's (more precisely the user with UID 0's) home directory

  • 14
    The reason root's home directory is not in /home is that /home is sometimes a separate filesystem, and sometimes mounted from a remote location. root needs to be able to log in and work without other filesystems mounted (i.e. single user mode). – TREE May 16 '16 at 14:48
6

/ is the root. /root is a folder called root in your root folder (/)

/home/enigma is your home folder; ie., where your documents are stored, your Desktop, your Music, your videos, your configuration files, etc. /media/enigma is the folder where removable devices, ex, USB sticks, external hard drives, cd's, etc. are mounted. In other words, if you want to access a removable drive, the place you would go to would be /media/enigma/1TB drive or whatever the name of your drive is.

  • 1
    so what are the stuffs that I can place in /root folder – BabyboB May 16 '16 at 12:55
  • 3
    The /root directory is for the root's configuration files. The vast majority of the time, we just leave that folder alone. We only touch it for debugging. It allows programs to have a default configuration if you run it as root. – anonymous2 May 16 '16 at 12:59
  • 1
    @BabyboB /root is used to store files in while you're root, just like /home/username is used when you're working as your normal user. However, since root really shouldn't be used unless you need it, you'll most likely have few files there - maybe a few deb-packages, maybe a few source-packages, maybe source-code being compiled, maybe a folder for root's mail (created by the mail-client). The most important stuff will perhaps be root's various configuration-files - like .bashrc, .wgetrc, .alpine, .mc, .screen, etc. - probably all hidden (use ls -a to see). – Baard Kopperud May 16 '16 at 17:29
  • @BaardKopperud nothing. It would be best to stay away from system directories. Keep your system directories clean and put things you need (for server/none-desktop related stuff ) in directories with "local" in them and for desktops in /home/$USER/. – Rinzwind May 16 '16 at 20:50
4

The difference between / and /root is easily to explain, / is the main tree (root) of the whole linux file-system and /root is the admin's user-directory equivalent to yours in /home/<username>.

2

A user's home directory is sometimes referred to as ~ and in the case of root that is /root/. For other users, perhaps users that cannot 'see' the rest of the system--they are chrooted into a directory where what they see is '/' as the base, even though parent directories exist.

If you can see 'everything'-- '/' is the topmost level of everything on the file system.

1

Picture of Linux filesystem

I just created a picture for you to make it clear. The Linux system is like a tree. The bottom of the tree is the "/". The /root is a folder on the "/" tree.

1

Your home directory is usually /home/$USER, but root's (administrator or superuser, the user that has full privileges) home directory is /root. Since you're not root, you're not able to see the contents inside /root without asking for root access (usually with the sudo command and a shell or file manager, e.g. sudo nautilus).

/ is the filesystem root. It is like the C:\ drive in Windows. The difference here is that other drives are mounted inside /, usually in /media/$USER/DRIVE (current user only) or in /mnt/DRIVE (for all users).

To sum up:

Inside your home folder, you'll find your Desktop, Documents, Downloads, etc. And inside your media folder you have your "mounted" drives (except for /, because it doesn't have to be mounted). So /root is just a home directory inside the real filesystem root.

Not the answer you're looking for? Browse other questions tagged or ask your own question.