MacOS – What’s the difference between hostname’s show and the hostname on the command line

macos

I use hostname for checking:

aircrafts-MacBook-Pro:~ ldl$ hostname
aircrafts-MacBook-Pro.local

there shows aircrafts-MacBook-Pro.local.

I want to know the difference between aircrafts-MacBook-Pro:~ ldl$'s aircrafts-MacBook-Pro and aircrafts-MacBook-Pro.local.

Best Answer

The hostname given by the "hostname" command is the fully qualified hostname (i.e. the full hostname including domains, etc.).

The one displayed in the prompt is shown because your /etc/bashrc file contains the following prompt definition for bash (your shell):

PS1='\h:\W \u\$ '

The first part of the prompt specification "\h" means that the hostname should be displayed in the prompt - but only the hostname up to the first . (dot).

That's why you see two different things.