Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a server with fqdn (this is in DNS) but I don't really want the machine to have git as its hostname.

It might not be clear exactly what I want. Or maybe I don't really understand how all this is supposed to work, but my understanding is that

hostname -f

Should return the fqdn of the server, which in this case is

And plain old hostname should return the UNqualified hostname of the server. Every resource I can find says the the unqualified name should be the start of the fqdn but this seems annoying and inconvenient.

I would like

hostname -f

To return since that really is the fqdn of the server

But I would like hostname to just return mycustomhostname.

At the moment I have /etc/hostname set as 'mycustomhostname', and in /etc/hosts I have mycustomhostname

Where is my public IP. However, this results in the hostname command returning mycustomhostname (which is fine), but hostname -f returns mycustomhostname as well, which is not correct, since the fqdn is

The main reason for this is that when I am ssh'ing in to the server I would like the bash shell to say


Instead of

myusername@git (Which is what ever guide everywhere seems to indicate it should be).

Simply because it will make it easier for me to know what server I am working with. If I have another server for git repositories (say, and follow the conventions I see everywhere, then if I ssh'd in to that server bash would also say


Which is confusing for me.

How do I properly have a different hostname to the server's fqdn?

This is on Debian Linux btw.

share|improve this question
You could create a DNS CNAME record for pointing to the server's IP or real host name Is there a particular reason you want to be the "real FQDN"? FWIW OS X's man hostname says: Include domain information in the printed name. This is the default behavior. [...] Trim off any domain information from the printed name.. There's no reference to those being completely different. – Daniel Beck Nov 29 '12 at 7:42
Is the fqdn not supposed to be the domain name of the server on the Internet? If I want to access this server through a browser I type So therefore shouldn't that be the fqdn? – Cameron Ball Nov 29 '12 at 7:49
Just add two lines to your ~/.ssh/config: Host mycustomhostname and HostName, in that order. See man ssh_config for details. This solves your original problem, but not the question as stated, so sadly not an answer. (You can even get rid of the myusername@ by adding a User myusername line; just running ssh mycustomhostname does the trick then, and both suggestions even trickle down to git (pun intended)) – Jonas Wielicki Oct 9 '14 at 19:07
up vote 1 down vote accepted

You can give your server the host name, and add an alias (CNAME) in DNS for to that host.

This way, it can be reached using, but it'll identify using its actual host name.

share|improve this answer

You can use as simple command:

# hostname -s

And see the result.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.