Ubuntu – How to go between partitions in terminal

command linepartitioning

A very basic query which requires your kind guidance. If I am at command prompt in either DOS or Windows, I would use, (if I am in C: drive) d: to go to drive D. What is the equivalent in Ubuntu Terminal if I want to move around between partitions, from sda1 to sda2 for example?

Best Answer

Ok, this is one of the fundamental differences between windows and linux. The Windows file system uses devices as starting points for each section of the file system. So you have:


Linux/Unix systems use the concept of a unified file system. Everything is under the root folder, and can be arbitrarily mixed together. The user and programs do not know about devices because they have been abstracted away. So, all linux systems will have the same general hierarchy.

A linux system will look something like this:


But these folder could be on the same hard drive, or separate hard drives. They can even be network folders! There is a special folder called /dev for if a program actually needs to talk to the physical device. So, anywhere that you want to go on a linux system will never require switching devices like on windows.

However, sometimes a device is not added to the filesytem! It will be plugged in, the OS can see it as a device, but it has not been mounted. Modern linux systems will try and do this for you as necessary. Sometimes it doesn't work, and you have to do it your self. That is what the mount command is for. It is also the original purpose of the /mnt folder, so you can have an obvious place to mount new sections of the file system.

Before mounting a drive:


After mounting drive to /mnt/temp:

        |---other stuff

So you can mount a drive, then use cd to move into it, or anywhere else in the file system. This allows for neat things, like having your /home directory on a separate hard drive, in case you want to switch linux distros later, or so you can back it up. The /tmp folder is often not on an actual device at all! It's could be some ram treated as a folder. That makes it easy to put stuff there, then have it cleaned up when you reboot.

Related Question