ホスト名をに永久に変更するにはどうすればよいですかdebian?

ホスト名をに永久に変更するにはどうすればよいですかdebian?

こんにちはLinuxコミュニティです。
VultrからVPSサービスを購入したため、Linuxがインストールされている家庭用のスタンドアロンPCではありません。私は彼らが「提供した」これらのあいまいなコントロールパネル設定を処理しなければなりませんでした。
有料のVPSインスタンスにオペレーティングシステムを再インストールしたときに問題が発生しました。
私はkali-linux(当時私のホスト名でもある)debian 11vpsインスタンスを削除しませんでした。ちょうどオペレーティングシステムを再インストールしました。私のIPは以前と同じです。

OSを次に変更した後、debian 11ホスト名も変更したかったのですが、debianここで問題が始まりました。

システムを再インストールした後、Vultrのクライアントパネルにホスト名を変更する特別なボタンがあることに気づき、それをクリックしてシステムをすばやく再インストールしました。すべてがうまくいくことを願っています。

ここに画像の説明を入力してください。

VPSにログインして/etc/hostnameクレームを確認してくださいdebian

rafal@debian:~$ cat /etc/hostname
debian

確認してみると/etc/hosts次のようになります。

rafal@debian:~$ cat /etc/hosts
# Your system has configured 'manage_etc_hosts' as True.
# As a result, if you wish for changes to this file to persist
# then you will need to either
# a.) make changes to the master file in /etc/cloud/templates/hosts.debian.tmpl
# b.) change or remove the value of 'manage_etc_hosts' in
#     /etc/cloud/cloud.cfg or cloud-config from user-data
#
127.0.1.1 kali_linux.edu kali_linux
127.0.0.1 localhost

# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

適格ドメイン名がないため、後に何を入力するのかわかりませんが127.0.1.1、そうしたくありませんkali_linux.edu

同じ行の最後kali_linuxdebian

このファイルを参照するコメント付きの行があることがわかります。/etc/cloud/templates/hosts.debian.tmplただし、Vimを使用して編集しようとすると、次の結果が表示されます。

E325: ATTENTION
Found a swap file by the name "/etc/cloud/templates/.hosts.debian.tmpl.swp"
          owned by: root   dated: Wed Jan 04 19:48:16 2023
         file name: /etc/cloud/templates/hosts.debian.tmpl
          modified: YES
         user name: root   host name: debian
        process ID: 1272
While opening file "/etc/cloud/templates/hosts.debian.tmpl"
             dated: Fri Dec 16 16:50:25 2011

(1) Another program may be editing the same file.  If this is the case,
    be careful not to end up with two different instances of the same
    file when making changes.  Quit, or continue with caution.
(2) An edit session for this file crashed.
    If this is the case, use ":recover" or "vim -r /etc/cloud/templates/hosts.debian.tmpl"
    to recover the changes (see ":help recovery").
    If you did this already, delete the swap file "/etc/cloud/templates/.hosts.debian.tmpl.swp"
    to avoid this message.

私はそれについて何も知りません。私が知る限り、スワップファイルは、物理RAMがいっぱいになったときにRAMメモリの一部をダンプするために使用されるファイルです。他のファイルのスワップファイルが何であるかわかりません:-(

しかし、ファイルは/etc/cloud/templates/hosts.debian.tmpl次のようになります。

## template:jinja
{#
This file (/etc/cloud/templates/hosts.debian.tmpl) is only utilized
if enabled in cloud-config.  Specifically, in order to enable it
you need to add the following to config:
   manage_etc_hosts: True
-#}
# Your system has configured 'manage_etc_hosts' as True.
# As a result, if you wish for changes to this file to persist
# then you will need to either
# a.) make changes to the master file in /etc/cloud/templates/hosts.debian.tmpl
# b.) change or remove the value of 'manage_etc_hosts' in
#     /etc/cloud/cloud.cfg or cloud-config from user-data
#
{# The value '{{hostname}}' will be replaced with the local-hostname -#}
127.0.1.1 {{fqdn}} {{hostname}}
127.0.0.1 localhost

# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

すべての混乱が原因でこのエラーが発生しました。sudo: unable to resolve host debian: Name or service not known.

rafal@debian:~$ sudo apt install unattended-upgrades
sudo: unable to resolve host debian: Name or service not known
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
unattended-upgrades is already the newest version (2.8).
The following packages were automatically installed and are no longer required:
  gir1.2-packagekitglib-1.0 libappstream4 libdw1 libglib2.0-bin libgstreamer1.0-0 libpackagekit-glib2-18 libstemmer0d libunwind8 packagekit
  packagekit-tools python3-software-properties software-properties-common
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

ホスト名をに永久に変更するにはどうすればよいですかdebian

ベストアンサー1

おすすめ記事