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/...
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♦
- 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,...
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() ...
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 ...
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 ...
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 ...
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 (...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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. ...
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: ...
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@...
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
...
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 ...
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, ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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.
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
hostname × 378linux × 60
dns × 49
networking × 44
hosts × 42
centos × 37
ssh × 37
debian × 28
ubuntu × 25
ip × 23
domain × 20
dhcp × 17
bash × 16
fedora × 16
ping × 13
systemd × 12
rhel × 11
prompt × 10
command-line × 9
raspberry-pi × 8
macos × 8
apache-httpd × 7
shell-script × 6
host-name-resolution × 6
arch-linux × 5