The macosxhints Forums

The macosxhints Forums (http://hintsforums.macworld.com/index.php)
-   UNIX - Newcomers (http://hintsforums.macworld.com/forumdisplay.php?f=15)
-   -   Very basic question (http://hintsforums.macworld.com/showthread.php?t=89526)

keyboard112 05-12-2008 05:16 AM

Very basic question
 
I recently installed a second hard drive on my g5. I was able in os x to mount the drive and copy all my files to it as a back up. I am new to unix so I was trying to view the new drive from terminal. I see it in the volumes dir but how do I view it, ls, cd? I try to cd to /volumes/backup 1 which does not work. I tried doing searches on google to find out but no luck. Could someone direct me where to look or explain how it is done. I did pdisk -l I can see the partition listed there, do I do anything with the dev dir to access it?

Thank you,
Keith

cwtnospam 05-12-2008 08:18 AM

You need to escape the space in the volume name.

Won't work:
cd /volumes/backup 1

Should work:
cd /volumes/backup\ 1

benwiggy 05-12-2008 08:43 AM

Don't forget that <tab> will auto-complete pathnames in Terminal. So if you don't want to bother typing in long names with multiple spaces, just hit <tab> when you've typed enough for it to be uniquely identified.

keyboard112 05-12-2008 03:06 PM

Escaping the space
 
Thank you so much! I was on another forum which I will not go back to, basically they would not help because it was such a basic question. I did not know that is what you do for the space. I was trying to do cd /volumes/backup 1... Thank you for your help what you suggested worked, I appreciate it.

Keith

trevor 05-12-2008 03:21 PM

cwtnospam's method of escaping a space is the best one for a couple reasons: it works with the tab complete method, and it's the established "unix" way to deal with spaces. However, there is another alternative way to deal with spaces--use quotations.

So cwtnospam's method is preferred (assuming that the Volume in question is named backup 1):

cd /Volumes/backup\ 1
but you can also use
cd /Volumes/"backup 1"
or single quotes
cd /Volumes/'backup 1'
or even put the quotations around more of the path, if you prefer, like
cd "/Volumes/backup 1"

But the REAL hardcore longbeard unixy way to do it is to not even use spaces in directory and file names. :-P

Trevor

keyboard112 05-13-2008 12:21 AM

quotes
 
Hello,

I was experimenting with changing directories with spaces as suggested several different ways here. Some of my directory names have " ' " in them ex. file type doc's, when I do cd /documents\ it does not read it properly but if I put the whole name in quotes it does. I take it there really should not be symbols or spaces in the names?

Thanks again,

Keith

tlarkin 05-13-2008 01:26 AM

Quote:

Originally Posted by trevor (Post 469189)

But the REAL hardcore longbeard unixy way to do it is to not even use spaces in directory and file names. :-P

Trevor

We have this old school Unix consultant that we call in for the heavy crazy big problems we can't figure out ourself. He names every files with underscores, and never uses spaces. Says it helps him sleep at night by doing so. he actually doesn't have a beard though, but I do......

Mikey-San 05-13-2008 01:28 AM

Quote:

Originally Posted by tlarkin (Post 469266)
We have this old school Unix consultant that we call in for the heavy crazy big problems we can't figure out ourself. He names every files with underscores, and never uses spaces. Says it helps him sleep at night by doing so. he actually doesn't have a beard though, but I do......

He doesn't when you see him only because a cron task runs at night to rotate his facial hair.

tlarkin 05-13-2008 01:41 AM

Quote:

Originally Posted by Mikey-San (Post 469267)
He doesn't when you see him only because a cron task runs at night to rotate his facial hair.

I need to get rid of my razor then and get one of those cron jobs to rotate out my facial hair. You could so make that a launchd item!

keyboard112 05-13-2008 01:44 AM

Unmounting a hard drive
 
Hello,

One more question, for now that is :) I have a usb hard drive I am trying to unmount in terminal it list as being mounted in the volumes dir. I tried different commands and terminal lists command not found. This is what I thought to be correct, / root# unmount /Volumes/"WD USB 2" is this something I have to do via diskutil in terminal or am I not using the proper command. I also tried unmount /dev/disk2s1 as well , using the device identifier.

Thanks again,

Keith

hayne 05-13-2008 02:13 AM

The correct command is "umount" (no 'n').
You can find out what commands relate to a given topic keyword with 'man -k':
Code:

% man -k unmount
automountd(8)            - automatic mount / unmount daemon for autofs
mount(2), unmount(2)    - mount or dismount a filesystem
umount(8)                - unmount filesystems

The numbers after the command names indicate the section of the man pages.
Things in section 2 are system-calls - these are only useful if you are writing a C program.

keyboard112 05-13-2008 03:01 AM

Umount
 
Quote:

Originally Posted by hayne (Post 469271)
The correct command is "umount" (no 'n').
You can find out what commands relate to a given topic keyword with 'man -k':
Code:

% man -k unmount
automountd(8)            - automatic mount / unmount daemon for autofs
mount(2), unmount(2)    - mount or dismount a filesystem
umount(8)                - unmount filesystems

The numbers after the command names indicate the section of the man pages.
Things in section 2 are system-calls - these are only useful if you are writing a C program.

Thank you, I even looked at the man page, I assumed mount/unmount, my fault I need to pay better attention.

Thanks again,

Keith

dv 05-13-2008 09:49 AM

newbie also
 
was trying to reformat a Lacie hard drive and erase everything on it and start again but was hit with a popup that said I was unable to "umount" the drive. How do I do that?

trevor 05-13-2008 11:40 AM

Quote:

Originally Posted by keyboard112 (Post 469264)
I was experimenting with changing directories with spaces as suggested several different ways here. Some of my directory names have " ' " in them ex. file type doc's,

You will have to escape the single quote symbol (') in names too, just like a space. So to create a file with a single quote, you'd use something like
% touch foo\'
% ls -l foo*
-rw-r--r-- 1 trevor trevor 0 May 13 09:33 foo'
% rm foo'
> (here, hit Control-C to exit out, it didn't work as planned)
% rm foo\'
%

Quote:

Originally Posted by keyboard112
when I do cd /documents\ it does not read it properly but if I put the whole name in quotes it does. I take it there really should not be symbols or spaces in the names?

The real unixy longbeard way is to not use symbols or spaces in names. But unix has for a long time allowed symbols or spaces in names, the longbeards just consider it to be gauche, a sign of poor education or something.

OS X, of course, allows symbols or spaces, and there are always ways to deal with them, such as escaping the characters, or putting names in quotations, or in some cases both at once.

Trevor

ganbustein 05-13-2008 07:47 PM

Quote:

Originally Posted by keyboard112 (Post 469264)
when I do cd /documents\

Quote:

Originally Posted by keyboard112 (Post 469264)
I try to cd to /volumes/backup 1

HFS+ is a case-insensitive filesystem, which lets you get away with typing volumes when you mean Volumes, documents when you mean Documents, etc.

But Unix grew up on filesystems where case matters, and it still insists on proper case in some places. Auto-completion is one of those. It won't auto-complete a filename if the prefix you type has the wrong case.

Example: you have a volume named "Backup 1" (and no other similarly-named volume):

/V<tab> will auto-expand to /Volumes/
/v<tab> just beeps. So will /volumes<tab>
/Volumes/Ba<tab> will auto-expand to /Volumes/Backup\ 1/
/Volumes/ba<tab> just beeps.
/volumes/Ba<tab> does work, though.

It's probably a good idea to get in the habit of being meticulous about case. You'll thank me when you try to use Unix on another platform.

keyboard112 05-14-2008 02:27 AM

Quote:

Originally Posted by ganbustein (Post 469413)
HFS+ is a case-insensitive filesystem, which lets you get away with typing volumes when you mean Volumes, documents when you mean Documents, etc.

But Unix grew up on filesystems where case matters, and it still insists on proper case in some places. Auto-completion is one of those. It won't auto-complete a filename if the prefix you type has the wrong case.

Example: you have a volume named "Backup 1" (and no other similarly-named volume):

/V<tab> will auto-expand to /Volumes/
/v<tab> just beeps. So will /volumes<tab>
/Volumes/Ba<tab> will auto-expand to /Volumes/Backup\ 1/
/Volumes/ba<tab> just beeps.
/volumes/Ba<tab> does work, though.

It's probably a good idea to get in the habit of being meticulous about case. You'll thank me when you try to use Unix on another platform.

Thank you Trevor,

I have another problem at hand I ran into. I have a usb 250 in fat32 formant. I am able to umount it with no problem but I am having issues mounting it. I have tried mount -t msdos /VOLUMES/"WD USB 2"
mount -a -t msdos or vfat /VOLUMES/"WD USB 2"
I have also tried diskutil from bash and i did diskutil mountDisk /VOLUMES/"WD USB 2" it stated it mounted. When I type mount I don't see it listed, when I cd to that partition I just see .autodiskmounted not the directories on it. When I reboot the mac the usb drive shows up as mounted and I can access everything on it. I am just trying to learn the ways of mount and Umont. I looked at the man pages I really didnt see anything but mount -t, when I looked on google I found mount -t msdos, and mount -t vfat for linux but neither worked. I am not sure what I am doing wrong at this point.

Thanks again ,

Keith

trevor 05-14-2008 10:08 AM

Quote:

I have tried mount -t msdos /VOLUMES/"WD USB 2"
mount -a -t msdos or vfat /VOLUMES/"WD USB 2"
See what ganbustein said above. The correct case of the /Volumes directory has the initial V capitalized and the rest of the letters in lower case.

You haven't told the mount command what you want to mount at the /Volumes/"WD USB 2" mountpoint. You will need to include the entry in /dev for the disk you are trying to mount, like /dev/disk2s9 (or whatever is the right entry).

When the disk in question is properly mounted, you can enter the command
diskutil -list
to see the relevant entry for the disk in /dev.

Then, put the /dev/diskwhatever in your mount command before the mountpoint. The example mount command given in the mount manual (type man mount to see it) is:

mount -t hfs -o nosuid,-w,-m=755 /dev/disk2s9 /tmp

In that case, dev/disk2s9 is the /dev entry, and /tmp is the mountpoint.

Trevor

keyboard112 05-15-2008 02:34 AM

Suggestions?
 
Quote:

Originally Posted by trevor (Post 469499)
See what ganbustein said above. The correct case of the /Volumes directory has the initial V capitalized and the rest of the letters in lower case.

You haven't told the mount command what you want to mount at the /Volumes/"WD USB 2" mountpoint. You will need to include the entry in /dev for the disk you are trying to mount, like /dev/disk2s9 (or whatever is the right entry).

When the disk in question is properly mounted, you can enter the command
diskutil -list
to see the relevant entry for the disk in /dev.

Then, put the /dev/diskwhatever in your mount command before the mountpoint. The example mount command given in the mount manual (type man mount to see it) is:

mount -t hfs -o nosuid,-w,-m=755 /dev/disk2s9 /tmp

In that case, dev/disk2s9 is the /dev entry, and /tmp is the mountpoint.

Trevor

Hi Trevor ,

I was able to get it to work! Thanks for your help, I don't always understand the man pages. I know some things are unique to darwin, is there something on the net I can look at to learn all the commands or things unique to darwin? A good reference point maybe or I was thinking I may need to find a good book, any suggestions. I love to research and read all I can before I bother any one to ask simple questions, sort of a last resort for me. I really appreciate the help here, some other sites are not so kind, I like to really try before I ask. I found this link along the way, http://www.matisse.net/OSX/darwin_commands.html.

Thanks again!!!

Keith

trevor 05-15-2008 01:14 PM

I'm biased, because the author is a friend of mine, but I like Mac OS X Unix 101 Byte-Sized Projects by Adrian Mayo.

There are also some very good O'Reilly books about OS X. For just one example, Learning Unix for OS X. (The linked version is for OS X Tiger, but there are also editions for other versions of OS X.)

Trevor

Lance666 01-02-2013 09:17 PM

Quote:

Originally Posted by trevor (Post 469499)

When the disk in question is properly mounted, you can enter the command
diskutil -list
to see the relevant entry for the disk in /dev.

Trevor

When I mount first, and then use the diskutil -list command, it says "unavailable due to being booted in single-user mode".

acme.mail.order 01-02-2013 09:27 PM

Quote:

Originally Posted by Lance666 (Post 715705)
When I mount first, and then use the diskutil -list command, it says "unavailable due to being booted in single-user mode".

So don't use it in single-user mode, which is intended exclusively for repairing serious computer-can't-boot issues, and it is intended to be used exclusively by the aforementioned unix longbeards (actual beard optional).

trevor 01-03-2013 01:55 PM

By the way, I'm not sure if the correct syntax back in 2008 was indeed
diskutil -list
or if I made a mistake back then, but today the correct syntax for that command is
diskutil list

--note that there is no hyphen before 'list'.

Trevor


All times are GMT -5. The time now is 10:14 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.