debian安装kali
Hostname is used to identify the Linux hosts. We generally prefer to put related host names to the systems like web1, db5 etc. In this tutorial we will look how to find and print hostname and change it with different methods. Following examples can be used for other Linux distributions like CentOS, Fedora, RedHat too.
主机名用于标识Linux主机。 通常,我们通常喜欢将相关的主机名添加到系统中,例如web1,db5等。在本教程中,我们将研究如何查找和打印主机名以及如何使用不同的方法对其进行更改。 以下示例也可用于其他Linux发行版,例如CentOS,Fedora,RedHat。
查找当前主机名 (Find Current Hostname)
There are different ways to find hostname. But the most easy and stable way is printing related host name configuration. Host name configuration is stored in /etc/hostname
which is very easy to find. We will print this configuration file like below.
有多种查找主机名的方法。 但是最简单,最稳定的方法是打印相关的主机名配置。 主机名配置存储在/etc/hostname
,这很容易找到。 我们将如下打印此配置文件。
$ cat /etc/hostname
使用hostnamectl命令查找当前主机名(Find Current Hostname with hostnamectl Command)
hostnamectl
is a new tool in order to manage host name configuration. We can print current hostname just providing hostnamectl
command like below. As we can more information can be found in the output like Operating system, machine UID etc.
hostnamectl
是用于管理主机名配置的新工具。 我们只需提供如下的hostnamectl
命令即可打印当前主机hostnamectl
。 我们可以在输出中找到更多信息,例如操作系统,计算机UID等。
$ hostnamectl
临时更改主机名(Change Hostname Temporary)
There is command named hostname
which is used to change hostname temporarily. We can provide the name we want to set. But we should have root
privileges for host name change.
有一个名为hostname
命令,用于临时更改主机名。 我们可以提供我们想要设置的名称。 但是我们应该具有更改主机名的root
特权。
$ sudo hostname poftut2
永久更改主机名(Change Host name Permanently)
We can change hostname permanatly too. Previous example will change hostname for current power up. After a reboot the host name will be reverted back. We will edit the hostname configuration file /etc/hostname
and put whatever we want.
我们也可以永久更改主机名。 前面的示例将更改当前启动的主机名。 重新启动后,主机名将恢复原状。 我们将编辑主机名配置文件/etc/hostname
并放入我们想要的任何内容。
$ sudo echo "poftut3" > /etc/hostname
使用hostnamectl更改主机名 (Change Host name with hostnamectl)
hostnamectl
command provides different options to list and set host name and related information. We will use set-hostname
option in order to change host name. We will set host name poftut4
like below.
hostnamectl
命令提供了不同的选项来列出和设置主机名以及相关信息。 我们将使用set-hostname
选项来更改主机名。 我们将像下面这样设置主机名poftut4
。
$ sudo hostnamectl set-hostname poftut4
翻译自: https://www.poftut.com/find-and-change-ubuntu-debian-kali-mint-hostname/
debian安装kali