{"id":2176,"date":"2026-02-24T19:18:28","date_gmt":"2026-02-24T10:18:28","guid":{"rendered":"https:\/\/kaizawa.jp\/?p=2176"},"modified":"2026-02-24T19:18:30","modified_gmt":"2026-02-24T10:18:30","slug":"sudo-hostnamectl-set-hostname-%e3%81%a8%e3%81%97%e3%81%9f%e3%82%89%e3%81%9d%e3%81%ae%e5%a0%b4%e3%81%af%e5%a4%89%e3%82%8f%e3%82%8b%e3%81%ae%e3%81%a7%e3%81%99%e3%81%8c%e3%80%81%e3%83%aa%e3%82%b9","status":"publish","type":"post","link":"https:\/\/kaizawa.jp\/?p=2176","title":{"rendered":"sudo hostnamectl set-hostname <\u65b0hostname>\u3068\u3057\u305f\u3089\u305d\u306e\u5834\u306f\u5909\u308f\u308b\u306e\u3067\u3059\u304c\u3001\u30ea\u30b9\u30bf\u30fc\u30c8\u3059\u308b\u3068\u307e\u305f\u5143\u306b\u623b\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002\u56fa\u5b9a\u3059\u308b\u306b\u306f\u3069\u3046\u3057\u305f\u3089\u3044\u3044\u3067\u3057\u3087\u3046\u3002Raspberry pi zero2w\u3067Ubuntu Server\u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u3002"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Raspberry Pi \u4e0a\u306e Ubuntu Server \u3067\u30db\u30b9\u30c8\u540d\u304c\u5143\u306b\u623b\u3063\u3066\u3057\u307e\u3046\u539f\u56e0\u306f\u3001\u521d\u671f\u8a2d\u5b9a\u30c4\u30fc\u30eb\u3067\u3042\u308b\u00a0<strong>cloud-init<\/strong>\u00a0\u304c\u8d77\u52d5\u6642\u306b\u8a2d\u5b9a\u3092\u4e0a\u66f8\u304d\u3057\u3066\u3044\u308b\u305f\u3081\u3067\u3059\u3002\u00a0<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u56fa\u5b9a\u3059\u308b\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u3044\u305a\u308c\u304b\u306e\u65b9\u6cd5\u3067 cloud-init \u306e\u8a2d\u5b9a\u3092\u5909\u66f4\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u65b9\u6cd51\uff1acloud-init \u306e\u30db\u30b9\u30c8\u540d\u7ba1\u7406\u3092\u7121\u52b9\u306b\u3059\u308b\uff08\u63a8\u5968\uff09<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u3053\u308c\u304c\u6700\u3082\u78ba\u5b9f\u306a\u65b9\u6cd5\u3067\u3059\u3002cloud-init \u306b\u3088\u308b\u30db\u30b9\u30c8\u540d\u306e\u81ea\u52d5\u8a2d\u5b9a\u3092\u30aa\u30d5\u306b\u3059\u308b\u3053\u3068\u3067\u3001<code>hostnamectl<\/code>&nbsp;\u3067\u306e\u8a2d\u5b9a\u304c\u7dad\u6301\u3055\u308c\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002&nbsp;<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u304d\u307e\u3059\u3002bash<code>sudo nano \/etc\/cloud\/cloud.cfg <\/code><\/li>\n\n\n\n<li><code>preserve_hostname: false<\/code>\u00a0\u3068\u3044\u3046\u884c\u3092\u63a2\u3057\u3001<strong><code>true<\/code><\/strong>\u00a0\u306b\u66f8\u304d\u63db\u3048\u307e\u3059\u3002yaml<code>preserve_hostname: true <\/code><\/li>\n\n\n\n<li>\u4fdd\u5b58\u3057\u3066\u7d42\u4e86\uff08Ctrl+O, Enter, Ctrl+X\uff09\u3057\u3001\u518d\u5ea6\u30db\u30b9\u30c8\u540d\u3092\u8a2d\u5b9a\u3057\u3066\u518d\u8d77\u52d5\u3057\u307e\u3059\u3002bash<code>sudo hostnamectl set-hostname &lt;\u65b0\u3057\u3044\u30db\u30b9\u30c8\u540d> sudo reboot <\/code><\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">\u65b9\u6cd52\uff1auser-data \u30d5\u30a1\u30a4\u30eb\u3092\u76f4\u63a5\u7de8\u96c6\u3059\u308b&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Raspberry Pi \u7248 Ubuntu \u306e\u5834\u5408\u3001<code>\/boot\/firmware\/user-data<\/code>\uff08\u307e\u305f\u306f&nbsp;<code>\/boot\/user-data<\/code>\uff09\u306b\u8a18\u8ff0\u3055\u308c\u3066\u3044\u308b\u30db\u30b9\u30c8\u540d\u304c\u512a\u5148\u3055\u308c\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002&nbsp;<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u304d\u307e\u3059\u3002bash<code>sudo nano \/boot\/firmware\/user-data <\/code><\/li>\n\n\n\n<li><code>hostname: ubuntu<\/code>\u00a0\u306e\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\u7b87\u6240\u3092\u3001\u5e0c\u671b\u306e\u30db\u30b9\u30c8\u540d\u306b\u66f8\u304d\u63db\u3048\u3066\u4fdd\u5b58\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li>\u518d\u8d77\u52d5\u3059\u308b\u3068\u53cd\u6620\u3055\u308c\u307e\u3059\u3002\u00a0<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">\u6ce8\u610f\u70b9<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u30db\u30b9\u30c8\u540d\u3092\u5909\u66f4\u3057\u305f\u5f8c\u306f\u3001<code>\/etc\/hosts<\/code>&nbsp;\u30d5\u30a1\u30a4\u30eb\u5185\u306b\u3042\u308b\u65e7\u30db\u30b9\u30c8\u540d\u3082\u65b0\u3057\u3044\u3082\u306e\u306b\u66f8\u304d\u63db\u3048\u3066\u304a\u304b\u306a\u3044\u3068\u3001<code>sudo<\/code>&nbsp;\u30b3\u30de\u30f3\u30c9\u5b9f\u884c\u6642\u306b\u300c\u540d\u524d\u89e3\u6c7a\u304c\u3067\u304d\u306a\u3044\u300d\u3068\u3044\u3063\u305f\u8b66\u544a\u304c\u51fa\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">bash<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo nano \/etc\/hosts\n<em># 127.0.1.1 \u306e\u6a2a\u306b\u3042\u308b\u65e7\u30db\u30b9\u30c8\u540d\u3092\u65b0\u3057\u3044\u3082\u306e\u306b\u5909\u66f4<\/em>\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u3053\u308c\u3089\u3092\u884c\u3063\u3066\u3082\u89e3\u6c7a\u3057\u306a\u3044\u5834\u5408\u3001<strong>\u7279\u5b9a\u306e\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u74b0\u5883\uff08DHCP\u30b5\u30fc\u30d0\u30fc\u5074\u3067\u306e\u5f37\u5236\u6307\u5b9a\u306a\u3069\uff09<\/strong>\u306e\u53ef\u80fd\u6027\u306f\u3042\u308a\u307e\u3059\u304b\uff1f<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Raspberry Pi \u4e0a\u306e Ubuntu Server \u3067\u30db\u30b9\u30c8\u540d\u304c\u5143\u306b\u623b\u3063\u3066\u3057\u307e\u3046\u539f\u56e0\u306f\u3001\u521d\u671f\u8a2d\u5b9a\u30c4\u30fc\u30eb\u3067\u3042\u308b\u00a0cloud-init\u00a0\u304c\u8d77\u52d5\u6642\u306b\u8a2d\u5b9a\u3092\u4e0a\u66f8\u304d\u3057\u3066\u3044\u308b\u305f\u3081\u3067\u3059\u3002\u00a0 \u56fa\u5b9a\u3059\u308b\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u3044\u305a\u308c\u304b\u306e\u65b9\u6cd5\u3067&hellip;<\/p>\n","protected":false},"author":1,"featured_media":2135,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[24],"tags":[],"class_list":["post-2176","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ai"],"_links":{"self":[{"href":"https:\/\/kaizawa.jp\/index.php?rest_route=\/wp\/v2\/posts\/2176","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kaizawa.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kaizawa.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kaizawa.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kaizawa.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2176"}],"version-history":[{"count":1,"href":"https:\/\/kaizawa.jp\/index.php?rest_route=\/wp\/v2\/posts\/2176\/revisions"}],"predecessor-version":[{"id":2177,"href":"https:\/\/kaizawa.jp\/index.php?rest_route=\/wp\/v2\/posts\/2176\/revisions\/2177"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kaizawa.jp\/index.php?rest_route=\/wp\/v2\/media\/2135"}],"wp:attachment":[{"href":"https:\/\/kaizawa.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2176"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kaizawa.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2176"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kaizawa.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2176"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}