-1

In the command below, I'm trying to get the hostname of the server I'm logged into. Please note that I'm on the actual server and not ssh'ed into another server!! I'm trying to get the hostname. Our server administrator was telling me the hostname is lvs-mcsec01, but when I call the hostname command, I get something different. It looks like it's giving me the fully qualified domain name using the alias as the prefix, and not the hostname. How do I get the hostname using a Linux command?

[root@test-sec01 ~]# hostname --fqdn
test-sec01.atg.org
[root@test-sec01 ~]# hostname -a

[root@test-sec01 ~]#

3 Answers3

1

The DNS or NIS entries might be different. Clarify with your system administrator which name is being used. You may need to edit /etc/hostname to make a change permanent.

# hostname
# cat /etc/hostname
# domainname
# dnsdomainname

Source: man hostname

durette
  • 164
0

The only way your question makes sense is if your system administrator meant NetBIOS/Active Directory/WINS hostname, which requires samba service to be installed and running in order to be accessible.

Try nmblookup -A <your_ip_address> - it should display what windows-users see instead of your real hostname (which is indeed accessible via hostname --fqdn command)

Anubioz
  • 3,835
  • 19
  • 23
0

You use the hostname or uname command to get or set the hostname.

A server admin can set any hostname they want, which may be completely different from the name the system has in your inventory, your CMDB, the name it has for your hypervisor in case of a VPS, it can have many different forward DNS records and again even a different reverse DNS record for each of it's IP-addresses. Consistency in those is somewhat recommended but in no way required.

CentOS 6 sets the hostname at boot from /etc/sysconfig/network and will resolve the (external) ip-addresses by default from /etc/hosts

HBruijn
  • 84,206
  • 24
  • 145
  • 224