# Terminal



## Glenmac (Dec 16, 2009)

I am brand new to Terminal and trying to learn it.  I have read OS manual and learning slowly but have 2 questions:
1)  When I open my Terminal app, instead of stating my computer name,  it has a number: __-___-___-___:, then ~user$.  Why is there a number instead of a name?

2)  When do you use a space in your commands and when should you not use a space-couldn't find a good explanation, just text examples.

I don't use Terminal now but it looks fun and I want to learn, cautiously!!
Thanks,
Glen


----------



## g/re/p (Dec 16, 2009)

Hello Glen - check out these links:

http://osxfaq.com/Tutorials/LearningCenter/

http://www.matisse.net/OSX/intro_unix/0_outline.html

http://acad.coloradocollege.edu/dept/PC/SciCompLab/UnixTutorial/


----------



## Glenmac (Dec 16, 2009)

g/re/p

Thanks for the beginners tutorials.  I will read them.

Glen


----------



## Glenmac (Dec 16, 2009)

Sorry, forgot to ask again........would you be able to answer my first question about why I have all those numbers in front of my name as below:
     68-187-201-214:~ glenmccleary$ 
Thank you,
Glen


----------



## ElDiabloConCaca (Dec 17, 2009)

More than likely, that's your IP address slightly modified to conform to the restrictions of a computer name... at least, that's what it looks like.

You can modify the bash prompt in a number of ways:

http://www.linuxselfhelp.com/howtos/Bash-Prompt/Bash-Prompt-HOWTO-2.html

...and a more involved and complicated example:

http://dougbarton.us/Bash/Bash-prompts.txt


----------



## Glenmac (Dec 17, 2009)

ElDiabloConCaca,

That is exactly what it is.  I checked my network settings.  How would that get into the computer name settings, since my understanding is that Terminal is not dependent upon any internet functions to apply?
Thanks....


----------



## ElDiabloConCaca (Dec 17, 2009)

It could be that that's your actual computer name -- you can verify this in the Sharing pane of the System Preferences.

Changing the name of your computer in the Sharing pane should also change the prompt in Terminal.


----------



## Glenmac (Dec 17, 2009)

I checked the sharing prefs and the computer name is set as _"my name's" iMac_.  That is what I thought was supposed to be in terminal.

Glen


----------



## ElDiabloConCaca (Dec 17, 2009)

The single quote (i.e. "Jeff*'*s iMac") is an invalid character; or, rather, it should be "escaped" when using it in a bash shell string.  Since it's invalid, the hostname in bash is probably defaulting to your IP address.

Try changing the name of your computer in the Sharing pane to something like "iMac of Jeff" instead of "Jeff's iMac" (or give it a clever name -- "Goliath" for a Mac Pro, "Frankenstein" for a heavily-modded Mac, etc.).  Use upper- and lowercase letters, dashes (no underscores), and numbers only.  Better yet, use upper- and lowercase letters only.  That should clear it up.


----------



## Glenmac (Dec 17, 2009)

Sorry for being so ignorant of terminal, the " " in the above were mine.  Here is what the Sharing gives as the name: _Glen McCleary&#8217;s iMac_.  Also message under the window states: _Computers on your local network can access your computer at: glen-mcclearys-imac.local_  Did not want to confuse you with my quotes.

Thanks


----------



## ElDiabloConCaca (Dec 17, 2009)

No, not the double-quotes encapsulating the computer name... the possessive, _single_ quote between "McCleary" and "s".


----------



## Randy Singer (Dec 17, 2009)

Glenmac said:


> I don't use Terminal now but it looks fun and I want to learn, cautiously!!



You might really like this product, then:

CLIX (free)
http://rixstep.com/4/0/clix/

CLIX (command line interface for OS X) provides a graphic interface for the command line.  With one click you can find the function of a command and choose from its extensive commands database and it shows you the proper syntax.  So you can learn how to use the command line without the danger of making a nasty mistake.


----------



## Glenmac (Dec 17, 2009)

Randy-Thanks for the answers. I will look at Clix.....
ElDiabloConCaca-_No, not the double-quotes encapsulating the computer name... the possessive, single quote between "McCleary" and "s"._-I again apologize for my ignorance...burt I am not sure what you are saying here.
Thanks


----------



## ElDiabloConCaca (Dec 18, 2009)

The single-quote character is invalid in terms of a UNIX hostname.  It is the 9th character from the left in the following string:

McCleary's iMac

...specifically, the single quote located between the 'y' and 's' characters.


```
M c C l e a r y ' s
                [b]^[/b]
                [b]^[/b]
                [b]^[/b]
```
_That_ guy, right there, above the arrows.  You need to get rid of that character in your computer name.


----------



## Glenmac (Dec 18, 2009)

Thank you for the detailed, in depth response.  I had already deleted 'it' and the IP code still remains in the Terminal window.  I don't know if it really makes any difference, I am not on a network, but would like to get it right. Here is what is now in the local hostname box when I go to Edit (in the Sharing pref):  _Glen-McClearys-iMac_.


----------



## belgiumes (Jan 8, 2010)

When do you use a space in your commands and when should you not use a space-couldn't find a good explanation, just text examples.


----------



## ElDiabloConCaca (Jan 8, 2010)

You use a space when it's appropriate, and when you're separating different parts of the command string (such as the binary name and any arguments you supply to the binary).

You use a space when there's a space in a filename or a binary and you're either launching that binary or supplying that filename as an argument to a binary.

I'm not sure I understand your question fully -- it sounds like you're asking something like, "When do you use a space in a sentence?"


----------



## simbalala (Jan 9, 2010)

belgiumes said:


> When do you use a space in your commands and when should you not use a space-couldn't find a good explanation, just text examples.



I think I can offer a simpler explanation.

Spaces separate arguments for shell commands, they're part of the syntax.

So if a file name (or any other part of the argument) contains a space itself you have to tell the command parser to ignore that particular space, not treat it as a separator.

A backslash \ tells the parser to treat the following character as a literal, don't interpret it, take it as is.

Enclosing an argument in double quotes "" tells the parser to treat all enclosed characters as literals, it's a string, don't attempt to parse it looking for instructions.


----------



## MrChrisMMiller (Jan 6, 2011)

Perfect, I was looking for something to help me learn more of the OS X Command line. 

thanks


----------



## Randy Singer (Jan 6, 2011)

If you want to learn how to use OS X's command line, this product is phenomenal:

CLIX (free)
http://rixstep.com/4/0/clix/

CLIX allows you to use the command line by showing you how, without the fear that you will make a terrible mistake and do something you shouldn't.


----------

