changing directory in Mac Terminal?

Joined
Nov 5, 2010
Messages
2
Reaction score
0
Points
1
Hi There,

I am trying to change directory in Mac terminal.

Currently, in my finder, the name for my computer is "Computer" but when I open up terminal, it says "localhost :~ myUsername$ ". So I think that somehow it is logged in under localhost?

The question is therefore, how do I change from localhost to "Computer" (the name of my computer) and how can I actually change the name of my computer to something more memorable?

I do have apache installed by default on my mac so I have somehow gone into this mode but I don't know how? Incorrect use of 'Sudo' ?

Hopefully someone can help.

cheers
Volterony
 

bobtomay

,
Retired Staff
Joined
Dec 22, 2006
Messages
26,561
Reaction score
677
Points
113
Location
Texas, where else?
Your Mac's Specs
15" MBP '06 2.33 C2D 4GB 10.7; 13" MBA '14 1.8 i7 8GB 10.11; 21" iMac '13 2.9 i5 8GB 10.11; 6S
Am not a Terminal guy.

But, to change the name of your MacIntosh HD to something else - click on it on the Desktop so that it is highlighted - press Enter - Type whatever name you would like to call it - Press Enter again.

You can also do the same thing in Finder if you don't have it showing on the Desktop.
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
15,762
Reaction score
2,100
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
Localhost is your computer's name..and it really doesn't matter much..

When you open up Terminal for the first time, you'll be in your home directory "/Users/<username>". You can confirm this by type 'pwd' at the prompt.

You can then do 'ls -l' to get a listing of all the files/directories there and this will match what you see in Finder.

From there on, if you want [C]hange [D]irectory to a specific directory, you do "cd <directory>"..

Regards
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
I do have apache installed by default on my mac so I have somehow gone into this mode but I don't know how? Incorrect use of 'Sudo' ?
I'm sorry, this may be some miscommunication, but this doesn't make any sense. Are you having an issue with sudo or Apache?
 
OP
V
Joined
Nov 5, 2010
Messages
2
Reaction score
0
Points
1
Hi

Thanks for all your kind responses and advice as it is all very helpful indeed.

With regard to the localhost/computer name issue Vansmith, my confusion is coming from the fact that my machine at work is called "MyComp" and when I open up terminal, I see MyComp: ~ myUsername$. However with my Mac Laptop, If I look in the finder, I see the computer name is "Computer" so I am assuming that if I opened up terminal it should show "Computer: ~ myUsername$". Beats me where Localhost came from because I did not specify that anywhere or change my computer name to localhost?

As for bringing Sudo into the equation, I know it gives you 'super user' access and I have used this command in terminal to configure mysql, so what I was meaning was maybe I have l accidentally changed something. Remember that localhost is the name for Apache that runs as a service on your mac already. Using Sudo gives you temporary root privileges so you can start and stop Apache from the command line (as well and do it by turning web sharing on). Apache is running fine and I can view locally developed webpages using localhost. Essentially could I have used sudo incorrectly to create my 'localhost' issue (that is, an issue until I am convinced otherwise)?

For further information, when I click on finder in the dock, under devices it has 3 things: Computer, iDisk, and Macintosh HD. In work, my finder says: MyComp, iDisk, and Macintosh HD. No mention of localhost anywhere!!

Ultimately how do I change my computer name then? Would I need to log in as root or could I just use a sudo command to do it?
Regards
Volterony
 
Joined
Feb 14, 2004
Messages
4,781
Reaction score
166
Points
63
Location
Groves, Texas
You can change your prompt to whatever you want it to be:Bash Prompt HOWTO
localhost is the system's reference name for your computer whatever it's name.
To change the name of your computer, go to System Preference/ Sharing and put a new name in the box.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top