Skip to main content
51 votes
Accepted

How to correctly set hostname and domain name?

Setting your hostname: You'll want to edit /etc/hostname with your new hostname. Then, run sudo hostname $(cat /etc/hostname). Setting your domain, assuming you have a resolvconf binary: In /etc/...
SYN's user avatar
  • 2,953
47 votes
Accepted

What's the point of the hostnamectl command?

Background hostnamectl is part of systemd, and provides a proper API for dealing with setting a server's hostnames in a standardized way. $ rpm -qf $(type -P hostnamectl) systemd-219-57.el7.x86_64 ...
slm's user avatar
  • 373k
37 votes
Accepted

What's the default file for `hostname`?

The hostname commands in common toolsets, including BusyBox, do not fall back to files when querying the hostname. They report solely what the kernel returns to them as the hostname from a system call,...
JdeBP's user avatar
  • 69.9k
30 votes

Does a computer system (Linux) only have one host name?

Yes, and no. The are two distinct things called hostnames. The "internal" hostname is basically a string kept by the kernel. This is the one returned by the hostname command (or the gethostname() ...
ilkkachu's user avatar
  • 142k
23 votes
Accepted

Mac OS command to resolve hostnames like "getent" on Linux

I think dscacheutil is what you're looking for. It supports caching, /etc/hosts, mDNS (for .local). dscacheutil -q host -a name foo.local Another option is dns-sd dns-sd -q foo.local More ...
user422009's user avatar
19 votes
Accepted

How to filter by host name in Wireshark?

The problem might be that Wireshark does not resolve IP addresses to host names and presence of host name filter does not enable this resolution automatically. To make host name filter work enable DNS ...
Petr Gladkikh's user avatar
18 votes
Accepted

How can you determine the hostname associated with an IP on the network?

The zeroconf protocol suite (Wikipedia) could provide this information. The best known implementations are AllJoyn (Windows and others), Bonjour (Apple), Avahi (UNIX/Linux). Example showing a list ...
Chris Davies's user avatar
17 votes
Accepted

How is an Elastic IP address different from a static IP address?

The main difference between the two is that: You will lose your Public IP when you Stop and Start the instance, while the EIP remains linked to the instance even after the Stop/Start operation (...
Echoes_86's user avatar
  • 752
16 votes

How to correctly set hostname and domain name?

sudo nano /etc/hostname hostname.domain.com sudo nano /etc/hosts 127.0.0.1 hostname.domain.com hostname localhost REBOOT! MUST HAVE SINGLE HOSTNAME after FQDN in /etc/hosts file. Works ...
Richard Westby-Nunn's user avatar
15 votes

Understand hostname and /etc/hosts

/etc/hostname and /etc/hosts are simple, but also not so simple... How to quickly setup Debian /etc/hostname and /etc/hosts 1) Edit /etc/hostname. There are 2 valid ways to set this up. Either ...
Elliptical view's user avatar
14 votes

How do I fix my problem with hostnamectl command. It cannot connect to dbus

It looks like dbus package is missing. Check if dbus package is installed or not using below command: $ sudo dpkg -l | grep dbus ii dbus 1.10.26-0+deb9u1 ...
Ram's user avatar
  • 182
14 votes
Accepted

Bash prompt takes only the first word of a hostname before the dot

In bash you can use two special characters regarding hostname: \h to get host name up to the first dot \H to get full host name If you want anything else you need to make your own version for ...
jimmij's user avatar
  • 47.8k
12 votes

Mac OS X Terminal Equivalent for Host Name Info

For the hostname -d, use hostname -f: hostname -f | sed -e 's/^[^.]*\.//' For IP-addresses, use ifconfig -a (look for the inet data). Your machine may have only one network device, en0, so you ...
Thomas Dickey's user avatar
12 votes

The difference between 'ping' and 'wget' in relation to hostname resolution

Answering to: What is the difference between 'ping' and 'wget' in relation to hostname resolution Ping expects either an IP address or a hostname as parameter. You are giving it a full URL which ...
jlliagre's user avatar
  • 61.8k
10 votes
Accepted

Shell command/script to see if a host is alive?

Ping is great to get a quick response about whether the host is connected to the network, but it often won't tell you whether the host is alive or not, or whether it's still operating as expected. ...
Malvineous's user avatar
  • 7,063
9 votes

How to correctly set hostname and domain name?

Instructions written against Ubuntu 18.04.3 LTS (bionic) Change the hostname: sudo hostnamectl set-hostname server1 Check result by running hostnamectl: root@www:/# hostnamectl Static hostname: ...
RobM's user avatar
  • 512
8 votes

How to show the host name in Linux commandline prompt

I like when the shell prompt shows the username, hostname and the name of the working directory. In addition, I like, when all of this is shown in colors. So I usually put export PS1='\[\033[0;32m\]\u@...
John Smith's user avatar
  • 2,817
8 votes
Accepted

How can I resolve an IP address to a hostname in Arch Linux?

You can use either host or nslookup from bind-tools: $ host 172.217.19.195 195.19.217.172.in-addr.arpa domain name pointer fra02s21-in-f3.1e100.net. $ nslookup 172.217.19.195 Server: 192.168.2.1 ...
Wieland's user avatar
  • 6,579
8 votes
Accepted

Set hostname on first boot before network.service

Nothing ensures that your firstboot.service runs before systemd-networkd is started. You have to use Wants=network-pre.target Before=network-pre.target instead of Before=network.target to achieve ...
Ferenc Wágner's user avatar
8 votes

What's the point of the hostnamectl command?

It is still a text file, you can still edit it, and there will not be a problem. The text file has been standardized to /etc/hostname. According to the maintainer, the services systemd-hostname, ...
sourcejedi's user avatar
  • 51.4k
8 votes
Accepted

NetworkManager interferes with hostname configuration

Ivanivan's answer (tuning dhcpcd.con), though plausible, didn't work in my case. So I suspect it is not about DHCP. I stumbled upon this post which told me that the problem is not about DHCP but about ...
LaTechneuse's user avatar
8 votes
Accepted

why host from bind9-host is/was deprecated and when?

host is not deprecated by Internet Systems Consortium, the BIND company. It does not even deprecate nslookup as it once did. This deprecation of host was done in 2018 by a Debian Developer, on xyr ...
JdeBP's user avatar
  • 69.9k
7 votes
Accepted

Why do some of my logs use Localhost and others Hostname - Different Servers

https://wiki.archlinux.org/index.php/rsyslog#Configure_Hostname Rsyslog uses the glibc routine gethostname() or gethostbyname() to determine the hostname of the local machine. The gethostname() or ...
sourcejedi's user avatar
  • 51.4k
7 votes

How to correctly set hostname and domain name?

~$ man hostname […] You cannot change the FQDN with hostname or dnsdomainname. The recommended method of setting the FQDN is to make the hostname be an alias for the fully ...
karlsebal's user avatar
  • 835
7 votes
Accepted

How can I find out the hostnames of other computers in the same local network?

Install nmap for whatever flavour of Linux you are on. Then perform: nmap -sP xxx.xxx.xxx.xxx/nn Where xxx.xxx.xxx.xxx/nn is your IP and subnet mask bits. For example, if you were on 192.168.1.0 ...
number9's user avatar
  • 1,074
6 votes

How to change hostname on CentOS 6.5?

Apart from the answers already provided for CentOS 6.5, CentOS 7 also has a text based user interface tool to change hostname (and other network settings), part of Network Manager: nmtui starts ...
quasoft's user avatar
  • 169
6 votes

Simple name server alternative a la /etc/hosts

Dnsmasq will serve up the data in your /etc/hosts file as a dns server - authoritative for your lical domain and providing caching for internet lookups. It also provides a dhcp server.
symcbean's user avatar
  • 5,936
6 votes
Accepted

How to find out nameserver which resolves a particular host name

There are several commands that are useful to debug DNS resolution, and to show the path travelled to resolve DNS lookpups: dnstracer Install it with: sudo apt-get install dnstracer example of ...
Rui F Ribeiro's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible