What is the equivalent for switching drives in terminal on Linux?











up vote
37
down vote

favorite
12












In DOS, I switch between different drives by typing c:, d:, e: and so forth. But it doesn't work that way in Linux.



Could anyone please tell me how to switch between different drives?










share|improve this question
























  • yep.. using linux for the first time. hav to learn a lot
    – saiy2k
    Feb 2 '12 at 6:37










  • Just to clarify as this is a usual misconception causing more trouble in understanding: DOSBox is an emulator, cmd.exe a command-line interpreter for non-DOS based Windows releases and COMMAND.COM a system shell for DOS. While user interaction with these programs and the appearance may be similar, they are not the same.
    – LiveWireBT
    Dec 13 '14 at 13:19















up vote
37
down vote

favorite
12












In DOS, I switch between different drives by typing c:, d:, e: and so forth. But it doesn't work that way in Linux.



Could anyone please tell me how to switch between different drives?










share|improve this question
























  • yep.. using linux for the first time. hav to learn a lot
    – saiy2k
    Feb 2 '12 at 6:37










  • Just to clarify as this is a usual misconception causing more trouble in understanding: DOSBox is an emulator, cmd.exe a command-line interpreter for non-DOS based Windows releases and COMMAND.COM a system shell for DOS. While user interaction with these programs and the appearance may be similar, they are not the same.
    – LiveWireBT
    Dec 13 '14 at 13:19













up vote
37
down vote

favorite
12









up vote
37
down vote

favorite
12






12





In DOS, I switch between different drives by typing c:, d:, e: and so forth. But it doesn't work that way in Linux.



Could anyone please tell me how to switch between different drives?










share|improve this question















In DOS, I switch between different drives by typing c:, d:, e: and so forth. But it doesn't work that way in Linux.



Could anyone please tell me how to switch between different drives?







command-line drive






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 13 '14 at 13:05









LiveWireBT

21.1k1770152




21.1k1770152










asked Feb 1 '12 at 17:40









saiy2k

288135




288135












  • yep.. using linux for the first time. hav to learn a lot
    – saiy2k
    Feb 2 '12 at 6:37










  • Just to clarify as this is a usual misconception causing more trouble in understanding: DOSBox is an emulator, cmd.exe a command-line interpreter for non-DOS based Windows releases and COMMAND.COM a system shell for DOS. While user interaction with these programs and the appearance may be similar, they are not the same.
    – LiveWireBT
    Dec 13 '14 at 13:19


















  • yep.. using linux for the first time. hav to learn a lot
    – saiy2k
    Feb 2 '12 at 6:37










  • Just to clarify as this is a usual misconception causing more trouble in understanding: DOSBox is an emulator, cmd.exe a command-line interpreter for non-DOS based Windows releases and COMMAND.COM a system shell for DOS. While user interaction with these programs and the appearance may be similar, they are not the same.
    – LiveWireBT
    Dec 13 '14 at 13:19
















yep.. using linux for the first time. hav to learn a lot
– saiy2k
Feb 2 '12 at 6:37




yep.. using linux for the first time. hav to learn a lot
– saiy2k
Feb 2 '12 at 6:37












Just to clarify as this is a usual misconception causing more trouble in understanding: DOSBox is an emulator, cmd.exe a command-line interpreter for non-DOS based Windows releases and COMMAND.COM a system shell for DOS. While user interaction with these programs and the appearance may be similar, they are not the same.
– LiveWireBT
Dec 13 '14 at 13:19




Just to clarify as this is a usual misconception causing more trouble in understanding: DOSBox is an emulator, cmd.exe a command-line interpreter for non-DOS based Windows releases and COMMAND.COM a system shell for DOS. While user interaction with these programs and the appearance may be similar, they are not the same.
– LiveWireBT
Dec 13 '14 at 13:19










7 Answers
7






active

oldest

votes

















up vote
22
down vote



accepted










Linux doesn't really have a way to work with "drives", per se, except with system utilities that access partitions; they often need to specify the drive that contains the partition. But if your drives each only have one partition, it doesn't really matter.



Anyway, to access a drive, you actually need to specify the partition in some way, usually by a definition like /dev/sda1 (1st partition on 1st drive) or /dev/sda2 (2nd partition on first drive). Using the Disk Utility or gparted, you can see all the partitions graphically. If you're only using the terminal, I've found that the command "blkid" is handy to list the drives with their UUIDs. I use the form:



sudo blkid -c /dev/null


Using the terminal, you need to mount a partition to actually use it. This is actually pretty easy to do. In most cases, you would want to use an empty directory as the "mount point"; if the directory is not empty, its contents will be masked and unavailable during the mount. This may be useful in certain circumstances, such as testing or temporarily changing a configuration for some other reason, as it will alleviate the need to rename or delete the current contents.



If you have a directory named /mnt/drive2 (/mnt is commonly used, but it can be in your home directory if you want), and your drive is /dev/sdb, with a single partition, then the simplest command is:



sudo mount -t type /dev/sdb1 /mnt/drive2


where "type" is the type shown in the blkid command, such as ntfs, ext4, etc.



EDIT: to experiment, don't be afraid to try the mount command. It is only temporary until you reboot (or unmount using the "umount" command). To make it permanent, you need to enter it into /etc/fstab. If you want to do that, you can experiment by creating an entry, then using the command "mount -a" to mount everything in /etc/fstab. If there are errors, it will tell you, and you can correct and repeat until it works.






share|improve this answer



















  • 1




    The first partition of the first drive is sda1, there is no sda0
    – enzotib
    Feb 1 '12 at 19:06










  • Oops, sorry, you're right. I've gotten so used to using UUIDs that I forgot that. And since I have a lot of partitions, I always have to look them up to see which one to use, so I don't think about it. I'll edit my answer, but make a note of it so your comment won't look out of place.
    – Marty Fried
    Feb 1 '12 at 19:28


















up vote
10
down vote













Hard disks (drives, as you call them) contain partitions, and each partition contain a filesystem.



In Linux and Unix there is a main filesystem called root filesystem, and indicated with /. Other filesystems (real or virtual) are mounted on the root filesystem on a mount point, i.e. an empty directory used as a start point for the specific filesystem, in such a way that all files can be reached as descendant of the root directory.



If you type the command mount without option, you would see something like the following:



sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs (rw,relatime,size=764668k,nr_inodes=191167,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=153392k,mode=755)
/dev/sda5 on / type ext4 (rw,noatime,errors=remount-ro,user_xattr,barrier=1,data=ordered)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,relatime,size=306784k)
tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,relatime,size=306784k)
/dev/sda7 on /media/data type ext4 (rw,noatime,user_xattr,acl,barrier=1,data=ordered)
rpc_pipefs on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
XXX.XXX.163.168:/media/data/ on /media/data/mnt type nfs4 (rw,nosuid,noexec,relatime,vers=4,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=XXX.XXX.163.76,minorversion=0,local_lock=none,addr=XXX.XXX.163.168)
gvfs-fuse-daemon on /home/enzotib/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000)


where you can see that the partition /dev/sda5 (5th partition of the hard disk /dev/sda) is mounted on /, so that it is the root partition.

Furthermore, you see /dev/sda7, another partition/filesystem, mounted on /media/data, so that cd /media/data effectively correspond to d: in the windows terminology.



There are many other mounted filesystem in this output, as you can see, and are all virtual filesystem, i.e. filesystem not corresponding to a disk partition. And you can see an NFS-mounted filesystem, a virtual filesystem linked to a real filesystem available on another machine through the network (the line of output where you see an IP address in part deliberately obscured by me).



You can see the simplicity of having a single structure to access all your files, and in some cases also remote files.



Related questions:




  • How to access a usb flash drive from the terminal? (How can I mount a flash drive manually?)


  • Why have both /mnt and /media? and How to understand the Ubuntu file system layout?






share|improve this answer



















  • 1




    Using lsblk may be a bit easier to read and only lists block storage devices (no sysfs, proc, cgroup, etc.).
    – LiveWireBT
    Dec 13 '14 at 13:06










  • cd ~ to get back to home directory
    – Aakash Shah
    Feb 16 '17 at 6:14






  • 1




    @AakashShah: cd ~ is a short version of cd, that do the same thing.
    – enzotib
    Feb 18 '17 at 18:05


















up vote
8
down vote













Ubuntu keeps all additional disks mounted in the /media directory, so use



cd /media/$USER/<your-drive-name>





share|improve this answer























  • Like the answer below, the directory is cd /media/$USER/<your drive name>.
    – Bobort
    Sep 13 at 20:26


















up vote
4
down vote













it's easy



cd /media/$USER/{the name of the drive}


in the future, if you forget it, just go to the drive with your files manager choose a random folder then right click on a blank area -> properties then see the "location"






share|improve this answer






























    up vote
    2
    down vote













    You can also just browse to the folder on the drive you want and right-click, open in terminal.






    share|improve this answer




























      up vote
      0
      down vote













      Ubuntu can use, from your home directory (eliminate the < and > and replace "yourusername" with your actual username you logged into Linux with, "drive name" with the name of your hard disk).



      cd /media/<yourusername>/<drive name>


      All mounted disks are in that /media/yourusername/ directory . If you do not know the drive name, you can always look in your file manager -or- through the terminal (again from your home directory)



      ls /media/<yourname>/


      You can use the sd# and mnt described; however, I think you were looking for an easy answer.






      share|improve this answer























      • The commands you've provided use absolute paths and are not required to be run from within the user's home directory.
        – jkt123
        Apr 23 '14 at 2:30


















      up vote
      0
      down vote













      Actually, for me it's like this:



      cd /media/<user>/New Volume/


      With New Volume being the name of the external drive.
      and user being my username.



      Don't know why the backward slash, I assume because of the space?






      share|improve this answer



















      • 2




        Yes, it's because of the space.
        – muru
        Dec 23 '15 at 8:01






      • 1




        Yes, I would avoid using Spaces in folder names or disk names or even file names. Just use CamelCase.
        – Bobort
        Sep 13 at 20:27











      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "89"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f100568%2fwhat-is-the-equivalent-for-switching-drives-in-terminal-on-linux%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      7 Answers
      7






      active

      oldest

      votes








      7 Answers
      7






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      22
      down vote



      accepted










      Linux doesn't really have a way to work with "drives", per se, except with system utilities that access partitions; they often need to specify the drive that contains the partition. But if your drives each only have one partition, it doesn't really matter.



      Anyway, to access a drive, you actually need to specify the partition in some way, usually by a definition like /dev/sda1 (1st partition on 1st drive) or /dev/sda2 (2nd partition on first drive). Using the Disk Utility or gparted, you can see all the partitions graphically. If you're only using the terminal, I've found that the command "blkid" is handy to list the drives with their UUIDs. I use the form:



      sudo blkid -c /dev/null


      Using the terminal, you need to mount a partition to actually use it. This is actually pretty easy to do. In most cases, you would want to use an empty directory as the "mount point"; if the directory is not empty, its contents will be masked and unavailable during the mount. This may be useful in certain circumstances, such as testing or temporarily changing a configuration for some other reason, as it will alleviate the need to rename or delete the current contents.



      If you have a directory named /mnt/drive2 (/mnt is commonly used, but it can be in your home directory if you want), and your drive is /dev/sdb, with a single partition, then the simplest command is:



      sudo mount -t type /dev/sdb1 /mnt/drive2


      where "type" is the type shown in the blkid command, such as ntfs, ext4, etc.



      EDIT: to experiment, don't be afraid to try the mount command. It is only temporary until you reboot (or unmount using the "umount" command). To make it permanent, you need to enter it into /etc/fstab. If you want to do that, you can experiment by creating an entry, then using the command "mount -a" to mount everything in /etc/fstab. If there are errors, it will tell you, and you can correct and repeat until it works.






      share|improve this answer



















      • 1




        The first partition of the first drive is sda1, there is no sda0
        – enzotib
        Feb 1 '12 at 19:06










      • Oops, sorry, you're right. I've gotten so used to using UUIDs that I forgot that. And since I have a lot of partitions, I always have to look them up to see which one to use, so I don't think about it. I'll edit my answer, but make a note of it so your comment won't look out of place.
        – Marty Fried
        Feb 1 '12 at 19:28















      up vote
      22
      down vote



      accepted










      Linux doesn't really have a way to work with "drives", per se, except with system utilities that access partitions; they often need to specify the drive that contains the partition. But if your drives each only have one partition, it doesn't really matter.



      Anyway, to access a drive, you actually need to specify the partition in some way, usually by a definition like /dev/sda1 (1st partition on 1st drive) or /dev/sda2 (2nd partition on first drive). Using the Disk Utility or gparted, you can see all the partitions graphically. If you're only using the terminal, I've found that the command "blkid" is handy to list the drives with their UUIDs. I use the form:



      sudo blkid -c /dev/null


      Using the terminal, you need to mount a partition to actually use it. This is actually pretty easy to do. In most cases, you would want to use an empty directory as the "mount point"; if the directory is not empty, its contents will be masked and unavailable during the mount. This may be useful in certain circumstances, such as testing or temporarily changing a configuration for some other reason, as it will alleviate the need to rename or delete the current contents.



      If you have a directory named /mnt/drive2 (/mnt is commonly used, but it can be in your home directory if you want), and your drive is /dev/sdb, with a single partition, then the simplest command is:



      sudo mount -t type /dev/sdb1 /mnt/drive2


      where "type" is the type shown in the blkid command, such as ntfs, ext4, etc.



      EDIT: to experiment, don't be afraid to try the mount command. It is only temporary until you reboot (or unmount using the "umount" command). To make it permanent, you need to enter it into /etc/fstab. If you want to do that, you can experiment by creating an entry, then using the command "mount -a" to mount everything in /etc/fstab. If there are errors, it will tell you, and you can correct and repeat until it works.






      share|improve this answer



















      • 1




        The first partition of the first drive is sda1, there is no sda0
        – enzotib
        Feb 1 '12 at 19:06










      • Oops, sorry, you're right. I've gotten so used to using UUIDs that I forgot that. And since I have a lot of partitions, I always have to look them up to see which one to use, so I don't think about it. I'll edit my answer, but make a note of it so your comment won't look out of place.
        – Marty Fried
        Feb 1 '12 at 19:28













      up vote
      22
      down vote



      accepted







      up vote
      22
      down vote



      accepted






      Linux doesn't really have a way to work with "drives", per se, except with system utilities that access partitions; they often need to specify the drive that contains the partition. But if your drives each only have one partition, it doesn't really matter.



      Anyway, to access a drive, you actually need to specify the partition in some way, usually by a definition like /dev/sda1 (1st partition on 1st drive) or /dev/sda2 (2nd partition on first drive). Using the Disk Utility or gparted, you can see all the partitions graphically. If you're only using the terminal, I've found that the command "blkid" is handy to list the drives with their UUIDs. I use the form:



      sudo blkid -c /dev/null


      Using the terminal, you need to mount a partition to actually use it. This is actually pretty easy to do. In most cases, you would want to use an empty directory as the "mount point"; if the directory is not empty, its contents will be masked and unavailable during the mount. This may be useful in certain circumstances, such as testing or temporarily changing a configuration for some other reason, as it will alleviate the need to rename or delete the current contents.



      If you have a directory named /mnt/drive2 (/mnt is commonly used, but it can be in your home directory if you want), and your drive is /dev/sdb, with a single partition, then the simplest command is:



      sudo mount -t type /dev/sdb1 /mnt/drive2


      where "type" is the type shown in the blkid command, such as ntfs, ext4, etc.



      EDIT: to experiment, don't be afraid to try the mount command. It is only temporary until you reboot (or unmount using the "umount" command). To make it permanent, you need to enter it into /etc/fstab. If you want to do that, you can experiment by creating an entry, then using the command "mount -a" to mount everything in /etc/fstab. If there are errors, it will tell you, and you can correct and repeat until it works.






      share|improve this answer














      Linux doesn't really have a way to work with "drives", per se, except with system utilities that access partitions; they often need to specify the drive that contains the partition. But if your drives each only have one partition, it doesn't really matter.



      Anyway, to access a drive, you actually need to specify the partition in some way, usually by a definition like /dev/sda1 (1st partition on 1st drive) or /dev/sda2 (2nd partition on first drive). Using the Disk Utility or gparted, you can see all the partitions graphically. If you're only using the terminal, I've found that the command "blkid" is handy to list the drives with their UUIDs. I use the form:



      sudo blkid -c /dev/null


      Using the terminal, you need to mount a partition to actually use it. This is actually pretty easy to do. In most cases, you would want to use an empty directory as the "mount point"; if the directory is not empty, its contents will be masked and unavailable during the mount. This may be useful in certain circumstances, such as testing or temporarily changing a configuration for some other reason, as it will alleviate the need to rename or delete the current contents.



      If you have a directory named /mnt/drive2 (/mnt is commonly used, but it can be in your home directory if you want), and your drive is /dev/sdb, with a single partition, then the simplest command is:



      sudo mount -t type /dev/sdb1 /mnt/drive2


      where "type" is the type shown in the blkid command, such as ntfs, ext4, etc.



      EDIT: to experiment, don't be afraid to try the mount command. It is only temporary until you reboot (or unmount using the "umount" command). To make it permanent, you need to enter it into /etc/fstab. If you want to do that, you can experiment by creating an entry, then using the command "mount -a" to mount everything in /etc/fstab. If there are errors, it will tell you, and you can correct and repeat until it works.







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Dec 13 '14 at 18:12

























      answered Feb 1 '12 at 18:39









      Marty Fried

      13.3k53746




      13.3k53746








      • 1




        The first partition of the first drive is sda1, there is no sda0
        – enzotib
        Feb 1 '12 at 19:06










      • Oops, sorry, you're right. I've gotten so used to using UUIDs that I forgot that. And since I have a lot of partitions, I always have to look them up to see which one to use, so I don't think about it. I'll edit my answer, but make a note of it so your comment won't look out of place.
        – Marty Fried
        Feb 1 '12 at 19:28














      • 1




        The first partition of the first drive is sda1, there is no sda0
        – enzotib
        Feb 1 '12 at 19:06










      • Oops, sorry, you're right. I've gotten so used to using UUIDs that I forgot that. And since I have a lot of partitions, I always have to look them up to see which one to use, so I don't think about it. I'll edit my answer, but make a note of it so your comment won't look out of place.
        – Marty Fried
        Feb 1 '12 at 19:28








      1




      1




      The first partition of the first drive is sda1, there is no sda0
      – enzotib
      Feb 1 '12 at 19:06




      The first partition of the first drive is sda1, there is no sda0
      – enzotib
      Feb 1 '12 at 19:06












      Oops, sorry, you're right. I've gotten so used to using UUIDs that I forgot that. And since I have a lot of partitions, I always have to look them up to see which one to use, so I don't think about it. I'll edit my answer, but make a note of it so your comment won't look out of place.
      – Marty Fried
      Feb 1 '12 at 19:28




      Oops, sorry, you're right. I've gotten so used to using UUIDs that I forgot that. And since I have a lot of partitions, I always have to look them up to see which one to use, so I don't think about it. I'll edit my answer, but make a note of it so your comment won't look out of place.
      – Marty Fried
      Feb 1 '12 at 19:28












      up vote
      10
      down vote













      Hard disks (drives, as you call them) contain partitions, and each partition contain a filesystem.



      In Linux and Unix there is a main filesystem called root filesystem, and indicated with /. Other filesystems (real or virtual) are mounted on the root filesystem on a mount point, i.e. an empty directory used as a start point for the specific filesystem, in such a way that all files can be reached as descendant of the root directory.



      If you type the command mount without option, you would see something like the following:



      sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
      proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
      udev on /dev type devtmpfs (rw,relatime,size=764668k,nr_inodes=191167,mode=755)
      devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
      tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=153392k,mode=755)
      /dev/sda5 on / type ext4 (rw,noatime,errors=remount-ro,user_xattr,barrier=1,data=ordered)
      tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
      tmpfs on /tmp type tmpfs (rw,nosuid,nodev,relatime,size=306784k)
      tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,relatime,size=306784k)
      /dev/sda7 on /media/data type ext4 (rw,noatime,user_xattr,acl,barrier=1,data=ordered)
      rpc_pipefs on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)
      fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
      XXX.XXX.163.168:/media/data/ on /media/data/mnt type nfs4 (rw,nosuid,noexec,relatime,vers=4,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=XXX.XXX.163.76,minorversion=0,local_lock=none,addr=XXX.XXX.163.168)
      gvfs-fuse-daemon on /home/enzotib/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000)


      where you can see that the partition /dev/sda5 (5th partition of the hard disk /dev/sda) is mounted on /, so that it is the root partition.

      Furthermore, you see /dev/sda7, another partition/filesystem, mounted on /media/data, so that cd /media/data effectively correspond to d: in the windows terminology.



      There are many other mounted filesystem in this output, as you can see, and are all virtual filesystem, i.e. filesystem not corresponding to a disk partition. And you can see an NFS-mounted filesystem, a virtual filesystem linked to a real filesystem available on another machine through the network (the line of output where you see an IP address in part deliberately obscured by me).



      You can see the simplicity of having a single structure to access all your files, and in some cases also remote files.



      Related questions:




      • How to access a usb flash drive from the terminal? (How can I mount a flash drive manually?)


      • Why have both /mnt and /media? and How to understand the Ubuntu file system layout?






      share|improve this answer



















      • 1




        Using lsblk may be a bit easier to read and only lists block storage devices (no sysfs, proc, cgroup, etc.).
        – LiveWireBT
        Dec 13 '14 at 13:06










      • cd ~ to get back to home directory
        – Aakash Shah
        Feb 16 '17 at 6:14






      • 1




        @AakashShah: cd ~ is a short version of cd, that do the same thing.
        – enzotib
        Feb 18 '17 at 18:05















      up vote
      10
      down vote













      Hard disks (drives, as you call them) contain partitions, and each partition contain a filesystem.



      In Linux and Unix there is a main filesystem called root filesystem, and indicated with /. Other filesystems (real or virtual) are mounted on the root filesystem on a mount point, i.e. an empty directory used as a start point for the specific filesystem, in such a way that all files can be reached as descendant of the root directory.



      If you type the command mount without option, you would see something like the following:



      sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
      proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
      udev on /dev type devtmpfs (rw,relatime,size=764668k,nr_inodes=191167,mode=755)
      devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
      tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=153392k,mode=755)
      /dev/sda5 on / type ext4 (rw,noatime,errors=remount-ro,user_xattr,barrier=1,data=ordered)
      tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
      tmpfs on /tmp type tmpfs (rw,nosuid,nodev,relatime,size=306784k)
      tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,relatime,size=306784k)
      /dev/sda7 on /media/data type ext4 (rw,noatime,user_xattr,acl,barrier=1,data=ordered)
      rpc_pipefs on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)
      fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
      XXX.XXX.163.168:/media/data/ on /media/data/mnt type nfs4 (rw,nosuid,noexec,relatime,vers=4,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=XXX.XXX.163.76,minorversion=0,local_lock=none,addr=XXX.XXX.163.168)
      gvfs-fuse-daemon on /home/enzotib/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000)


      where you can see that the partition /dev/sda5 (5th partition of the hard disk /dev/sda) is mounted on /, so that it is the root partition.

      Furthermore, you see /dev/sda7, another partition/filesystem, mounted on /media/data, so that cd /media/data effectively correspond to d: in the windows terminology.



      There are many other mounted filesystem in this output, as you can see, and are all virtual filesystem, i.e. filesystem not corresponding to a disk partition. And you can see an NFS-mounted filesystem, a virtual filesystem linked to a real filesystem available on another machine through the network (the line of output where you see an IP address in part deliberately obscured by me).



      You can see the simplicity of having a single structure to access all your files, and in some cases also remote files.



      Related questions:




      • How to access a usb flash drive from the terminal? (How can I mount a flash drive manually?)


      • Why have both /mnt and /media? and How to understand the Ubuntu file system layout?






      share|improve this answer



















      • 1




        Using lsblk may be a bit easier to read and only lists block storage devices (no sysfs, proc, cgroup, etc.).
        – LiveWireBT
        Dec 13 '14 at 13:06










      • cd ~ to get back to home directory
        – Aakash Shah
        Feb 16 '17 at 6:14






      • 1




        @AakashShah: cd ~ is a short version of cd, that do the same thing.
        – enzotib
        Feb 18 '17 at 18:05













      up vote
      10
      down vote










      up vote
      10
      down vote









      Hard disks (drives, as you call them) contain partitions, and each partition contain a filesystem.



      In Linux and Unix there is a main filesystem called root filesystem, and indicated with /. Other filesystems (real or virtual) are mounted on the root filesystem on a mount point, i.e. an empty directory used as a start point for the specific filesystem, in such a way that all files can be reached as descendant of the root directory.



      If you type the command mount without option, you would see something like the following:



      sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
      proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
      udev on /dev type devtmpfs (rw,relatime,size=764668k,nr_inodes=191167,mode=755)
      devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
      tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=153392k,mode=755)
      /dev/sda5 on / type ext4 (rw,noatime,errors=remount-ro,user_xattr,barrier=1,data=ordered)
      tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
      tmpfs on /tmp type tmpfs (rw,nosuid,nodev,relatime,size=306784k)
      tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,relatime,size=306784k)
      /dev/sda7 on /media/data type ext4 (rw,noatime,user_xattr,acl,barrier=1,data=ordered)
      rpc_pipefs on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)
      fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
      XXX.XXX.163.168:/media/data/ on /media/data/mnt type nfs4 (rw,nosuid,noexec,relatime,vers=4,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=XXX.XXX.163.76,minorversion=0,local_lock=none,addr=XXX.XXX.163.168)
      gvfs-fuse-daemon on /home/enzotib/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000)


      where you can see that the partition /dev/sda5 (5th partition of the hard disk /dev/sda) is mounted on /, so that it is the root partition.

      Furthermore, you see /dev/sda7, another partition/filesystem, mounted on /media/data, so that cd /media/data effectively correspond to d: in the windows terminology.



      There are many other mounted filesystem in this output, as you can see, and are all virtual filesystem, i.e. filesystem not corresponding to a disk partition. And you can see an NFS-mounted filesystem, a virtual filesystem linked to a real filesystem available on another machine through the network (the line of output where you see an IP address in part deliberately obscured by me).



      You can see the simplicity of having a single structure to access all your files, and in some cases also remote files.



      Related questions:




      • How to access a usb flash drive from the terminal? (How can I mount a flash drive manually?)


      • Why have both /mnt and /media? and How to understand the Ubuntu file system layout?






      share|improve this answer














      Hard disks (drives, as you call them) contain partitions, and each partition contain a filesystem.



      In Linux and Unix there is a main filesystem called root filesystem, and indicated with /. Other filesystems (real or virtual) are mounted on the root filesystem on a mount point, i.e. an empty directory used as a start point for the specific filesystem, in such a way that all files can be reached as descendant of the root directory.



      If you type the command mount without option, you would see something like the following:



      sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
      proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
      udev on /dev type devtmpfs (rw,relatime,size=764668k,nr_inodes=191167,mode=755)
      devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
      tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=153392k,mode=755)
      /dev/sda5 on / type ext4 (rw,noatime,errors=remount-ro,user_xattr,barrier=1,data=ordered)
      tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
      tmpfs on /tmp type tmpfs (rw,nosuid,nodev,relatime,size=306784k)
      tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,relatime,size=306784k)
      /dev/sda7 on /media/data type ext4 (rw,noatime,user_xattr,acl,barrier=1,data=ordered)
      rpc_pipefs on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)
      fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
      XXX.XXX.163.168:/media/data/ on /media/data/mnt type nfs4 (rw,nosuid,noexec,relatime,vers=4,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=XXX.XXX.163.76,minorversion=0,local_lock=none,addr=XXX.XXX.163.168)
      gvfs-fuse-daemon on /home/enzotib/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000)


      where you can see that the partition /dev/sda5 (5th partition of the hard disk /dev/sda) is mounted on /, so that it is the root partition.

      Furthermore, you see /dev/sda7, another partition/filesystem, mounted on /media/data, so that cd /media/data effectively correspond to d: in the windows terminology.



      There are many other mounted filesystem in this output, as you can see, and are all virtual filesystem, i.e. filesystem not corresponding to a disk partition. And you can see an NFS-mounted filesystem, a virtual filesystem linked to a real filesystem available on another machine through the network (the line of output where you see an IP address in part deliberately obscured by me).



      You can see the simplicity of having a single structure to access all your files, and in some cases also remote files.



      Related questions:




      • How to access a usb flash drive from the terminal? (How can I mount a flash drive manually?)


      • Why have both /mnt and /media? and How to understand the Ubuntu file system layout?







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Apr 13 '17 at 12:25









      Community

      1




      1










      answered Feb 1 '12 at 18:12









      enzotib

      62.2k5131153




      62.2k5131153








      • 1




        Using lsblk may be a bit easier to read and only lists block storage devices (no sysfs, proc, cgroup, etc.).
        – LiveWireBT
        Dec 13 '14 at 13:06










      • cd ~ to get back to home directory
        – Aakash Shah
        Feb 16 '17 at 6:14






      • 1




        @AakashShah: cd ~ is a short version of cd, that do the same thing.
        – enzotib
        Feb 18 '17 at 18:05














      • 1




        Using lsblk may be a bit easier to read and only lists block storage devices (no sysfs, proc, cgroup, etc.).
        – LiveWireBT
        Dec 13 '14 at 13:06










      • cd ~ to get back to home directory
        – Aakash Shah
        Feb 16 '17 at 6:14






      • 1




        @AakashShah: cd ~ is a short version of cd, that do the same thing.
        – enzotib
        Feb 18 '17 at 18:05








      1




      1




      Using lsblk may be a bit easier to read and only lists block storage devices (no sysfs, proc, cgroup, etc.).
      – LiveWireBT
      Dec 13 '14 at 13:06




      Using lsblk may be a bit easier to read and only lists block storage devices (no sysfs, proc, cgroup, etc.).
      – LiveWireBT
      Dec 13 '14 at 13:06












      cd ~ to get back to home directory
      – Aakash Shah
      Feb 16 '17 at 6:14




      cd ~ to get back to home directory
      – Aakash Shah
      Feb 16 '17 at 6:14




      1




      1




      @AakashShah: cd ~ is a short version of cd, that do the same thing.
      – enzotib
      Feb 18 '17 at 18:05




      @AakashShah: cd ~ is a short version of cd, that do the same thing.
      – enzotib
      Feb 18 '17 at 18:05










      up vote
      8
      down vote













      Ubuntu keeps all additional disks mounted in the /media directory, so use



      cd /media/$USER/<your-drive-name>





      share|improve this answer























      • Like the answer below, the directory is cd /media/$USER/<your drive name>.
        – Bobort
        Sep 13 at 20:26















      up vote
      8
      down vote













      Ubuntu keeps all additional disks mounted in the /media directory, so use



      cd /media/$USER/<your-drive-name>





      share|improve this answer























      • Like the answer below, the directory is cd /media/$USER/<your drive name>.
        – Bobort
        Sep 13 at 20:26













      up vote
      8
      down vote










      up vote
      8
      down vote









      Ubuntu keeps all additional disks mounted in the /media directory, so use



      cd /media/$USER/<your-drive-name>





      share|improve this answer














      Ubuntu keeps all additional disks mounted in the /media directory, so use



      cd /media/$USER/<your-drive-name>






      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Nov 26 at 9:17









      Zanna

      49.2k13123234




      49.2k13123234










      answered Oct 16 '13 at 2:33









      Pratap Singh

      18113




      18113












      • Like the answer below, the directory is cd /media/$USER/<your drive name>.
        – Bobort
        Sep 13 at 20:26


















      • Like the answer below, the directory is cd /media/$USER/<your drive name>.
        – Bobort
        Sep 13 at 20:26
















      Like the answer below, the directory is cd /media/$USER/<your drive name>.
      – Bobort
      Sep 13 at 20:26




      Like the answer below, the directory is cd /media/$USER/<your drive name>.
      – Bobort
      Sep 13 at 20:26










      up vote
      4
      down vote













      it's easy



      cd /media/$USER/{the name of the drive}


      in the future, if you forget it, just go to the drive with your files manager choose a random folder then right click on a blank area -> properties then see the "location"






      share|improve this answer



























        up vote
        4
        down vote













        it's easy



        cd /media/$USER/{the name of the drive}


        in the future, if you forget it, just go to the drive with your files manager choose a random folder then right click on a blank area -> properties then see the "location"






        share|improve this answer

























          up vote
          4
          down vote










          up vote
          4
          down vote









          it's easy



          cd /media/$USER/{the name of the drive}


          in the future, if you forget it, just go to the drive with your files manager choose a random folder then right click on a blank area -> properties then see the "location"






          share|improve this answer














          it's easy



          cd /media/$USER/{the name of the drive}


          in the future, if you forget it, just go to the drive with your files manager choose a random folder then right click on a blank area -> properties then see the "location"







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 12 '14 at 21:42









          muru

          135k19286485




          135k19286485










          answered Dec 12 '14 at 17:10









          Sangimed

          1765




          1765






















              up vote
              2
              down vote













              You can also just browse to the folder on the drive you want and right-click, open in terminal.






              share|improve this answer

























                up vote
                2
                down vote













                You can also just browse to the folder on the drive you want and right-click, open in terminal.






                share|improve this answer























                  up vote
                  2
                  down vote










                  up vote
                  2
                  down vote









                  You can also just browse to the folder on the drive you want and right-click, open in terminal.






                  share|improve this answer












                  You can also just browse to the folder on the drive you want and right-click, open in terminal.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Oct 3 '15 at 1:12









                  hreryrtr

                  291




                  291






















                      up vote
                      0
                      down vote













                      Ubuntu can use, from your home directory (eliminate the < and > and replace "yourusername" with your actual username you logged into Linux with, "drive name" with the name of your hard disk).



                      cd /media/<yourusername>/<drive name>


                      All mounted disks are in that /media/yourusername/ directory . If you do not know the drive name, you can always look in your file manager -or- through the terminal (again from your home directory)



                      ls /media/<yourname>/


                      You can use the sd# and mnt described; however, I think you were looking for an easy answer.






                      share|improve this answer























                      • The commands you've provided use absolute paths and are not required to be run from within the user's home directory.
                        – jkt123
                        Apr 23 '14 at 2:30















                      up vote
                      0
                      down vote













                      Ubuntu can use, from your home directory (eliminate the < and > and replace "yourusername" with your actual username you logged into Linux with, "drive name" with the name of your hard disk).



                      cd /media/<yourusername>/<drive name>


                      All mounted disks are in that /media/yourusername/ directory . If you do not know the drive name, you can always look in your file manager -or- through the terminal (again from your home directory)



                      ls /media/<yourname>/


                      You can use the sd# and mnt described; however, I think you were looking for an easy answer.






                      share|improve this answer























                      • The commands you've provided use absolute paths and are not required to be run from within the user's home directory.
                        – jkt123
                        Apr 23 '14 at 2:30













                      up vote
                      0
                      down vote










                      up vote
                      0
                      down vote









                      Ubuntu can use, from your home directory (eliminate the < and > and replace "yourusername" with your actual username you logged into Linux with, "drive name" with the name of your hard disk).



                      cd /media/<yourusername>/<drive name>


                      All mounted disks are in that /media/yourusername/ directory . If you do not know the drive name, you can always look in your file manager -or- through the terminal (again from your home directory)



                      ls /media/<yourname>/


                      You can use the sd# and mnt described; however, I think you were looking for an easy answer.






                      share|improve this answer














                      Ubuntu can use, from your home directory (eliminate the < and > and replace "yourusername" with your actual username you logged into Linux with, "drive name" with the name of your hard disk).



                      cd /media/<yourusername>/<drive name>


                      All mounted disks are in that /media/yourusername/ directory . If you do not know the drive name, you can always look in your file manager -or- through the terminal (again from your home directory)



                      ls /media/<yourname>/


                      You can use the sd# and mnt described; however, I think you were looking for an easy answer.







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Apr 23 '14 at 1:57

























                      answered Apr 23 '14 at 1:50









                      user272792

                      11




                      11












                      • The commands you've provided use absolute paths and are not required to be run from within the user's home directory.
                        – jkt123
                        Apr 23 '14 at 2:30


















                      • The commands you've provided use absolute paths and are not required to be run from within the user's home directory.
                        – jkt123
                        Apr 23 '14 at 2:30
















                      The commands you've provided use absolute paths and are not required to be run from within the user's home directory.
                      – jkt123
                      Apr 23 '14 at 2:30




                      The commands you've provided use absolute paths and are not required to be run from within the user's home directory.
                      – jkt123
                      Apr 23 '14 at 2:30










                      up vote
                      0
                      down vote













                      Actually, for me it's like this:



                      cd /media/<user>/New Volume/


                      With New Volume being the name of the external drive.
                      and user being my username.



                      Don't know why the backward slash, I assume because of the space?






                      share|improve this answer



















                      • 2




                        Yes, it's because of the space.
                        – muru
                        Dec 23 '15 at 8:01






                      • 1




                        Yes, I would avoid using Spaces in folder names or disk names or even file names. Just use CamelCase.
                        – Bobort
                        Sep 13 at 20:27















                      up vote
                      0
                      down vote













                      Actually, for me it's like this:



                      cd /media/<user>/New Volume/


                      With New Volume being the name of the external drive.
                      and user being my username.



                      Don't know why the backward slash, I assume because of the space?






                      share|improve this answer



















                      • 2




                        Yes, it's because of the space.
                        – muru
                        Dec 23 '15 at 8:01






                      • 1




                        Yes, I would avoid using Spaces in folder names or disk names or even file names. Just use CamelCase.
                        – Bobort
                        Sep 13 at 20:27













                      up vote
                      0
                      down vote










                      up vote
                      0
                      down vote









                      Actually, for me it's like this:



                      cd /media/<user>/New Volume/


                      With New Volume being the name of the external drive.
                      and user being my username.



                      Don't know why the backward slash, I assume because of the space?






                      share|improve this answer














                      Actually, for me it's like this:



                      cd /media/<user>/New Volume/


                      With New Volume being the name of the external drive.
                      and user being my username.



                      Don't know why the backward slash, I assume because of the space?







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Dec 23 '15 at 8:01









                      muru

                      135k19286485




                      135k19286485










                      answered Dec 23 '15 at 8:00









                      Mookey

                      2,945112554




                      2,945112554








                      • 2




                        Yes, it's because of the space.
                        – muru
                        Dec 23 '15 at 8:01






                      • 1




                        Yes, I would avoid using Spaces in folder names or disk names or even file names. Just use CamelCase.
                        – Bobort
                        Sep 13 at 20:27














                      • 2




                        Yes, it's because of the space.
                        – muru
                        Dec 23 '15 at 8:01






                      • 1




                        Yes, I would avoid using Spaces in folder names or disk names or even file names. Just use CamelCase.
                        – Bobort
                        Sep 13 at 20:27








                      2




                      2




                      Yes, it's because of the space.
                      – muru
                      Dec 23 '15 at 8:01




                      Yes, it's because of the space.
                      – muru
                      Dec 23 '15 at 8:01




                      1




                      1




                      Yes, I would avoid using Spaces in folder names or disk names or even file names. Just use CamelCase.
                      – Bobort
                      Sep 13 at 20:27




                      Yes, I would avoid using Spaces in folder names or disk names or even file names. Just use CamelCase.
                      – Bobort
                      Sep 13 at 20:27


















                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Ask Ubuntu!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.





                      Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                      Please pay close attention to the following guidance:


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f100568%2fwhat-is-the-equivalent-for-switching-drives-in-terminal-on-linux%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Mont Emei

                      Province de Neuquén

                      Journaliste