How to change hostname on debian
How to change hostname on Debian 10 Linux
last updated July 13, 2019 in CategoriesDebian / Ubuntu, Linux
How do I change the hostname of a Debian Linux 10 “Buster” operating system permanently using the command line tools?
You can use the hostnamectl command or hostname command to display or set the Debian Linux system’s host name. In this tutorial, you will learn how to change your hostname on Debian Linux.
Change hostname on Debian 10 Linux
- Login to your server: ssh user@server-name
- Become a root user using either sudo -s or su -
- To set the hostname to server1, run: hostnamectl set-hostname server1
- Edit the file /etc/hosts and update entries: vi /etc/hosts
- Verify it by running the hostnamectl command again.
Let us see all commands in details.
Display the current hostname for Debian Linux
Simply run the following command:hostnamectl
The current hostname is set to localhost
Change the hostname on Debian 10
Now you know how to view the current hostname. It is time to change it as per your needs. A hostname is nothing but a name that identifies your Debian box on a network. Typically for the server, you set it as FQDN (fully qualified domain name) such as server1.cyberciti.biz. The syntax is as follows:hostnamectl set-hostname {name-here}
For example, to change the system hostname to deb10.cyberciti.biz in Debian 10, you can use the following command:sudo hostnamectl set-hostname deb10.cyberciti.biz
Next, edit the /etc/hosts file, run:vi /etc/hosts
Find all references to oldname and replace with newname except for the following entries:
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
For example:
127.0.0.1 localhost
192.168.2.100 deb10.cyberciti.biz # The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
Save and close the file.
Verify the change
How do you know that hostname was successfully changed? You use the same command without any arguments. In other words, type the following command:hostnamectl
Set a particular pretty host name
The syntax is:hostnamectl set-hostname "Vivek's Thinkpad" --pretty
Changing Debian host names remotely using ssh
From your Linux desktop, run:hostnamectl set-hostname -H [username]@hostname
hostnamectl set-hostname {new_name_here} -H root@192.168.2.10
hostnamectl set-hostname www42.nixcraft.com -H root@192.168.2.10
The hostnamectl tool will use SSH to connect to the remote system. One can see help page by typing:hostnamectl --help
Sample help page:
hostnamectl [OPTIONS...] COMMAND ... |
Conclusion
On Debian Linux hostnamectl command used to query and change the system hostname and related settings. For more information see the man page here.
How to change hostname on debian的更多相关文章
- How to change hostname on SLE
修改/etc/HOSTNAME文件,在此文件中保存主机名,例如: linuxserv1 然后运行命令设置主机名 # /etc/rc.d/boot.localnet start 方法3. 运行 sysc ...
- Change hostname and IP on Soalris10
To see the existing configuration: # ifconfig -a Update the following files for IP Address: /etc/hos ...
- bat 实现主机hostname的修改
主机实现hostname的修改原理: 修改注册表中的值: hklm\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName 下的 Comp ...
- linux的hostname(主机名)修改详解
Linux操作系统的hostname是一个kernel变量,可以通过hostname命令来查看本机的hostname.也可以直接cat /proc/sys/kernel/hostname查看. #ho ...
- Armbian hostname and WiFi configuration
In previous post i have described installation of Armbian on Orange Pi PC Plus. Now is the time for ...
- Ubuntu Server 18.04 无法修改 hostname
对于运维而言,我们希望每台服务器的 hostname 都能体现出它自己的功能/ip,方便排查. ubuntu server live 18.04 的安装流程非常友好,从 ip 到 hostname 都 ...
- Linux & change username & computer name & .bashrc
Linux & change username & computer name ubuntu change username and computer name https://ask ...
- SIHA环境修改主机名实施步骤
目 录 1 实施需求 2 修改主机名 2.1 停止HAS服务 2.2 修改主机名 3 重新配置服务 3.1 使用root用户重新配置CSS & OHAS服务 3.2 设置cssd自动启动属性 ...
- Centos6安装Gitlab
安装参考 https://about.gitlab.com/downloads/ 可以从清华的镜像下载安装包, 注意区分自己用的是哪个发行版 https://mirror.tuna.tsinghua. ...
随机推荐
- tp5.1 根据IP地址获取用户所在省市(个人笔记)
class IPAddress extends Common { /** * 根据ip地址,获取用户所在省市 */ public function ipIndex() { $ip = "22 ...
- 一秒可生成500万ID的分布式自增ID算法—雪花算法 (Snowflake,Delphi 版)
概述 分布式系统中,有一些需要使用全局唯一ID的场景,这种时候为了防止ID冲突可以使用36位的UUID,但是UUID有一些缺点,首先他相对比较长,另外UUID一般是无序的. 有些时候我们希望能使用一种 ...
- springboot2.x 使用redis (入门)
在使用之前先简单介绍一下,redis和mongoDB这两个nosql的区别以及使用场景. 1. redis redis是一个分布式缓存.高性能的key-value数据库.支持存储的value类型包括s ...
- delphi xe6 窗口 visible 不能隐藏 解决
delphi xe6 窗口 visible 不能隐藏 解决 在工程代码里面加上 Application.ShowMainForm := false;
- JDK和J2EE有什么关系
JDK(Java Development Kit)是Java 开发工具J2EE是Java一个平台 Java 平台有三个版本,这使软件开发人员.服务提供商和设备生产商可以针对特定的市场进行开发:* Ja ...
- asp.net core 3.1 中Synchronous operations are disallowed. Call FlushAsync or set AllowSynchronousIO to true instead
在Action中解决措施: var syncIOFeature = HttpContext.Features.Get<IHttpBodyControlFeature>(); if (syn ...
- 在ASP.NET MVC中加载部分视图的方法及差别
在视图里有多种方法可以加载部分视图,包括Partial() .Action().RenderPartial().RenderAction().RenderPage()方法.下面说明一下这些方法的差别. ...
- AWS--Lamdba
分享一个Lambda相关的连接 https://blog.csdn.net/m0_37204491/article/details/72829477
- Django:缓存及相关配置
缓存 由于Django是动态网站,所有每次请求均会去数据进行相应的操作,当程序访问量大时,耗时必然会更加明显,最简单解决方式是使用:缓存,缓存将一个某个views的返回值保存至内存或者memcache ...
- css3 text-fill-color属性
text-fill-color是什么意思呢?单单从字面上来看就是“文本填充颜色”,不过它实际也是设置对象中文字的填充颜色,和color的效果很相似.如果同时设置text-fill-color和colo ...