Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

how to cd into a thumb drive from terminal ( Mac OSX )

Writer Andrew Mclaughlin

How do i change into the directory of my thumbdrive? I've been poking around and see that this command, "diskutil list", lists all my local disks. That produces this..

David-Adamss-MacBook-Pro:~ davidadams$ diskutil list
/dev/disk0 #: TYPE NAME SIZE IDENTIFIER 0: GUID_partition_scheme *250.1 GB disk0 1: EFI 209.7 MB disk0s1 2: Apple_HFS Macintosh HD 249.7 GB disk0s2
/dev/disk3 #: TYPE NAME SIZE IDENTIFIER 0: FDisk_partition_scheme *4.0 GB disk3 1: DOS_FAT_32 THUMBDRIVE 4.0 GB disk3s1

now i see that my thumbdrive is showing up in /dev/disk3 but i can't get to it. I can cd into /dev but thats as far as i can get.

"cd /dev/disk3/THUMBDRIVE" tells me "-bash: cd: /dev/disk3/THUMBDRIVE: Not a directory"

any help would be great.

1

5 Answers

# cd /Volumes && ls

It will show you the directory location of all mounted volumes. Then just cd into the drive you want.

Mac OS X mounts drives automatically under /Volumes.

mress:10042 Z$ diskutil list
/dev/disk0 #: TYPE NAME SIZE IDENTIFIER 0: GUID_partition_scheme *1.0 TB disk0 1: EFI 209.7 MB disk0s1 2: Apple_HFS mress HD 999.9 GB disk0s2
/dev/disk1 #: TYPE NAME SIZE IDENTIFIER 0: Apple_partition_scheme *1.0 TB disk1 1: Apple_partition_map 32.3 KB disk1s1 2: Apple_HFS mress™ 1.0 TB disk1s3
/dev/disk2 #: TYPE NAME SIZE IDENTIFIER 0: GUID_partition_scheme *1.5 TB disk2 1: EFI 209.7 MB disk2s1 2: Apple_HFS Development 512.2 GB disk2s2 3: Apple_HFS Media 987.7 GB disk2s3
mress:10043 Z$ ls /Volumes
Development/ Media/ mress HD@ mress™/

You'll notice the directories match the NAME column.

0

In Terminal, if you

ls /Volumes

you'll see all of your drives. You can then cd to one of them (or just cd directly - no need to list the volumes first). For example:

cd /Volumes/My\ Other\ Drive

Spaces are replaced by '\ '. Or you can put the whole thing in quotes:

cd /Volumes/"My Other Drive"

If the drive name has no spaces, then you'd just use the name:

cd /Volumes/MyOtherDrive

If you drag and drop the icon corresponding to the volume on the USB drive from the Desktop (or Finder) into the Terminal window, it will automatically paste the path where that volume is mounted. This will most likely be a path in /Volumes.

ypuou have to mount it first.

#mkdir /media/myusbstick
#mount /dev/disk3 /media/myusbstick
# cd /media/myusbstick

make a directory, then mount then cd into it

You need to be root to do this, there are ways to set it up so users can mount like common GUI's do, but that is beyond me

EDIT: sorry you tagged your post with linux,?? but you have a mac? This is for linux, if you were curious

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy