Linux command(hostnamectl)

说明和使用

hostnamectl 是一个用于管理系统主机名的命令行工具,可以用来查看和设置系统的主机名。以下是 hostnamectl 命令的说明和使用方法:

查看当前主机名:

$ hostnamectl

查看主机名详细信息,包括静态和动态的主机名:

$ hostnamectl status

查看主机名的静态信息:

$ hostnamectl --static

查看主机名的动态信息:

$ hostnamectl --transient

查看主机名的 Pretty 格式(用户友好的名称):

$ hostnamectl --pretty

设置新的静态主机名:

$ sudo hostnamectl set-hostname new-hostname

设置新的动态主机名:

$ sudo hostnamectl set-hostname new-hostname --transient

设置新的 Pretty 主机名:

$ sudo hostnamectl set-hostname new-hostname --pretty

设置时区:

$ sudo timedatectl set-timezone Asia/Shanghai

重启主机:

$ sudo systemctl reboot

请注意,在设置主机名时需要使用管理员权限,使用 sudo 命令。另外,设置主机名后可能需要重启系统才能使改动生效。

Simply put

hostnamectl is a command-line tool used to query and control the system hostname and related settings in Linux distributions that use systemd. Here is an explanation of the command and its usage:

  • hostnamectl is used to interact with the system’s hostname settings.
  • By running hostnamectl without any options, it displays the current hostname and related information.
  • To set a new hostname, you can use the set-hostname option followed by the desired hostname. For example: sudo hostnamectl set-hostname newhostname .
  • To check the status and details of the system’s hostname configuration, you can use the status option. For example: hostnamectl status .
  • hostnamectl also provides options to control the static hostname, transient hostname, and chassis type.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

P("Struggler") ?

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值