Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a server with fqdn (this is in DNS) but I don't really want the machine to have git as its hostname. Right now I have the hostname in /etc/hostname set as (for example):


And in /etc/hosts I have mycustomhostname

(Where is my server's IP)

I've read that the first component of the FQDN should always be the unqualified hostname, so is what I'm doing bad?

If so, what is the correct way to do what I want?

edit: 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

Following the instructions of one of the answers, I added an alias in /etc/hosts which looks like this: mycustomhostname

And /etc/hostname is still just mycustomhostname

However, this results in the hostname command returning mycustomhostname (which is fine), but hostname -f returns mycustomhostname as well, which is not what I want.

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


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

3 Answers 3

up vote 2 down vote accepted

Why not leave the FQDN alone and just use a CNAME and always refer to it by the CNAME?

share|improve this answer
Can you elaborate on this? From what I understand a CNAME is done in DNS. What would I do on my server? –  Cameron Ball Nov 29 '12 at 6:24
What you are wanting to do now based on your extra comments should really be done backwards (your ssh requirement). Only internal? Change the FQDN and hostname to "" and then set a CNAME as "". External as well? Do the same as internal and have your external DNS resolve to as the A record. To create the CNAME you do that in DNS, so we would need to know what kind of DNS for both internal and external. –  TheCleaner Nov 29 '12 at 14:29
I ended up doing this. Thanks. –  Cameron Ball Nov 30 '12 at 1:12

Use a local host address for your host name in your hosts file, and associate the public address with the public IP. mycustomhostname
share|improve this answer
What about /etc/hostname is it correct to leave that as mycustomhostname? –  Cameron Ball Nov 29 '12 at 6:32

You could modify your shell's prompt to whatever you want without changing the hostname at all.

/etc/profile should be a good starting point for this.

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.