Linux Network Basics
Linux hostname and IP identity is the pair of labels that tells the network which machine is speaking: the hostname is the human name of the server, and the IP address is the numeric label that traffic actually uses to reach it.

You can read both in under 30 seconds, and you can change the hostname in 2 minutes with a single command. On a fresh Ubuntu 22.04 box the default name often looks like ubuntu-22-04 and the address often starts with 192.168, while a public host shows a different value entirely. This page walks through the exact commands, one by one.
The fastest path is to learn four things: how to read the name, how to read the address, how to change the name, and how to verify the change. Those four commands cover 90% of day one on a new server.
How to read the hostname
The command that prints the name is hostname, and its companion that prints the fully qualified domain name is hostname -f. If the machine is not in a domain, the two return the same string. A typical output looks like this:
hostname
web-01
hostname -f
web-01.example.org
The short name is web-01 and the FQDN adds the domain. When you type commands into a terminal, the prompt usually carries the short name, so user@web-01:~$ already tells you who you are on the box. If you are working through a structured set of Linux Commands, this is the first one worth memorising, because you will type it every time you open a new session.
How to find the IP address
Windows users reach for ipconfig, but Linux has no ipconfig binary; the two tools that replace it are ip and ifconfig. The modern, recommended tool is ip, which comes from the iproute2 package. To see every address on every interface, run ip addr. The output lists each interface, its MAC address, and its IPv4 and IPv6 values. A short version of the output looks like this:
ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536
inet 127.0.0.1/8 scope host lo
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500
inet 10.0.0.15/24 scope global eth0
inet6 fe80::a00:27ff:fe0c:3c1d/64 scope link
Three values appear, and each serves a different job. The 127.0.0.1 address on lo is the loopback interface, used only for local processes talking to each other. The 10.0.0.15 address on eth0 is the private address on your local network, in the 10.0.0.0/8 range. The fe80 value is the link-local IPv6 address, used for neighbour discovery before a global address is assigned. If you only need the one address that other hosts on your LAN will use, the 10.0.0.15 value is the one to copy.
If ip is not present, ifconfig is the fallback. It is older, it lives in the net-tools package, and its output is less structured, but it still works. The equivalent command is ifconfig eth0, and it returns the same 10.0.0.15 value under the inet line. Many older tutorials still show ifconfig, and that is why the search term Linux ipconfig shows up so often: people are looking for the command that does the job Windows users call ipconfig.
How to change the hostname
The command that changes the name is hostnamectl, and it works on any system that runs systemd, which includes every modern distribution. The syntax is hostnamectl set-hostname newname. To rename the box to web-01, you run:
sudo hostnamectl set-hostname web-01
The change takes effect for the current session immediately, and it persists across reboots because the command writes to /etc/hostname. If you check with hostname again, the prompt updates. If the machine is in a domain and you only want to change the short name, the same command handles it; the domain part is separate and lives in the DNS or search domain configuration.
Two rules keep the new name valid. First, the name must match the DNS label rules: lowercase letters, digits, and hyphens, starting and ending with a letter or digit, and at most 63 characters. Second, if the host is part of a cluster, a domain, or a Kubernetes node, you will also want to update the DNS record or the registry entry so that other machines can resolve the new name. Skipping that step leaves the name changed on the box but unresolvable from the outside.
Before systemd, the change was a two-step edit: you ran sudo hostname newname for the live session, then you edited /etc/hostname by hand so the change survived a reboot. That is the origin of the search phrase linux change hostname, and the older method still appears in scripts that target Debian 8 or earlier. On any system from the last decade, hostnamectl is the one command that does both steps at once.
Verifying the change
After you set the new name, run hostnamectl status and confirm that the line reading Static hostname shows the value you typed. Then open a second shell and run hostname again. Both should return the new name. If you set a FQDN with the --transient flag, the value is only in memory and will revert after a reboot, so drop that flag for a permanent change.
Static, dynamic, or link-local: which address do you need
The IP value you read depends on what the machine is for, and there are three categories to keep straight. A static address is assigned by the network administrator or burned into the DHCP server as a reservation, and it is the right choice for a server that other systems connect to by name. A dynamic address is handed out by DHCP on boot and can change, and it is the right choice for a laptop or a test box. A link-local address, in the 169.254.0.0/16 range for IPv4, is auto-assigned when DHCP fails, and it is a signal that something is wrong rather than a usable identity.
On a production host you want a static value, because the DNS record points at that value and a change breaks every client that caches the old one. If you are running a container or a VM that you will tear down, a dynamic value is fine, because nothing external depends on it. The 10.0.0.15 address from the earlier example is a private static-style value in the 10.0.0.0/8 space, and it is the kind of value you would write into a DNS A record.
When the address is missing or wrong
If ip addr shows an interface with no inet line, the host has no IPv4 address on that interface, and the usual cause is that DHCP did not run or the cable or the switch port is down. If the only inet value is 169.254.something, DHCP timed out and the kernel fell back to link-local. If the value is present but in the wrong subnet, the host will talk to the local segment but not to the rest of the network, which shows up as a ping that reaches the gateway but never reaches the target.
Three checks resolve most of these cases. First, confirm the interface is up with ip link and look for the UP flag. Second, confirm the cable or the virtual switch with ethtool eth0, which reports the link state. Third, request a lease explicitly with sudo dhclient eth0 and watch whether a new inet line appears. If the address is wrong rather than missing, the fix is in the DHCP server or the static configuration file under /etc/netplan or /etc/sysconfig/network-scripts, depending on the distribution, and the change requires a reboot or a network restart to apply.
Keeping the name and the address in sync
Hostname and address are two halves of the same identity, and the sync between them is what DNS enforces. The hostname is the label you type, and the address is the value DNS returns when you look the label up. When the two agree, a client that types ssh [email protected] reaches the right box. When the two disagree, the name resolves to the wrong address, or to nothing, and the failure looks like a network problem even though the server is fine.
For a single host on a trusted network, you can skip DNS entirely and let clients resolve the name through their local /etc/hosts file, which maps a name to an address with one line per entry. For anything shared, put the mapping in the zone file on the DNS server so that every client gets the same answer. The value in the zone file is the same 10.0.0.15 address from earlier, and the label is the same web-01.example.org name from the hostnamectl step. Keeping those two in lock step is the whole job, and the four commands on this page are the four checks that confirm they are.
For a structured path past day one, a Linux learning sequence that covers networking, DNS, and systemd in that order gives you the context that makes these four commands click. And if the server you are setting up will eventually run the Linux Kernel on bare metal or in a VM, the hostname and address choices you make here are the same choices you will revisit when you add the second host, the third, and the load balancer in front of them.