It gives an idea about what Raspberry Pi and Raspbian are and what are the uses of those. This article is aimed at people who are new to the world of Raspberry Pi. will show the static hostname as "n/a", the transient hostname set to localhost (which is used when the hostname is presented to the network services), and the pretty hostname to null, so it isn't displayed, After rebooting, that's how the hostnames will still be set.Ĭomments? Thoughts? Drop me a line or comment below then follow me on Twitter and Facebook. will launch an SSH session, connect to the target machine, request your password, and set the hostnames accordingly (you can also use the -static, -transient, and -pretty options with -H).įinally, under Raspbian, specifying an empty string ( "") without specifying a hostname: Sudo hostnamectl -H set-hostname “Barkometer” Perhaps it's a bug but the transient hostname can be set to a string that isn't RFC 1123 complaint and which is then used when the hostname is required.Ī cool feature of hostnamectl is the ability to remotely set hostnames using SSH so, if the host you're on and the target machine you want to rename both have hostnamectl installed: Here's an example of having set the pretty hostname to "Barkometer" (which is then transformed to "barkometer" for the static hostname) then having set the transient hostname to something different, for example, "Test": but note that hostnamectl won't allow you to specifically set a static hostname to a string that isn't RFC 1123 complaint. Sudo hostnamectl -pretty set-hostname “barkometer” Sudo hostnamectl -static set-hostname “barkometer” Sudo hostnamectl -transient set-hostname “barkometer” You can specifically set any of the three hostnames, for example: Note in the above screenshot that if the pretty hostname is specified and the static hostname wasn't then the pretty name will be made RFC 1123 compliant by replacing uppercase with lowercase and spaces with underscores, and by omitting special characters before it's copied into the static hostname. Again, you must use sudo or the command will fail. sets the static, and pretty hostnames (the transient hostname is set to null, i.e. Sudo hostnamectl set-hostname “Barkometer” There are actually three hostnames: Static, transient, and "pretty" the latter is a string that can contain any characters including those that can't be used in RFC 1123 hostnames. If a static hostname is set, and is valid (something other than localhost), then the transient hostname is not used. "lennarts-laptop"), and the transient hostname which is a fallback value received from network configuration. "Lennart's Laptop"), the static hostname which is used to initialize the kernel hostname at boot (e.g. … distinguishes three different hostnames: the high-level "pretty" hostname which might include all kinds of special characters (e.g. This command, which is available on pretty much every Linux distro including Raspbian: Want an even easier way to change your Raspberry Pi’s hostname? Try using hostnamectl. Whatever you do, DO NOT change 127.0.1.1 if you do, you will be annoyed by the consequences. If you change the last line, in this case, 127.0.1.1 raspberrypi, to something else, say, 127.0.1.1 barkometer (in honor of my Barkometer series), then, after rebooting, that will be your machine’s hostname.
0 Comments
Leave a Reply. |