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. ...
随机推荐
- 学Python要避免哪些坑,如何巩固好基础
学Python要避免哪些坑?零基础怎么入门Python?Python入门简单.语法简洁.功能强大,非常适合零基础入门IT行业的人学习.随着人工智能时代的来临,企业纷纷选择使用Python进行开发,Py ...
- Python的基本数据类型2
1.str(字符串) 1.切片 str = "你好,我是Python" s = str[0:4] #用法[start:end:step],指定开始下标和结束下标,step是步长,默 ...
- golang使用json格式实现增删查改
需求和思路 在一般的小项目或者一个小软件,例如客户端之类的小程序中,可能会需要数据的持久化.但是使用一般的数据库(Mysql)之类的不合适.使用sqlite3这种嵌入式的是个较好的方法,但是Go语言中 ...
- bootstrap-wizard向导插件的使用
引用文件 <link rel="stylesheet" href="bootstrap-wizard/bootstrap-wizard.css"> ...
- centos 7 搭建 k8s
环境 Centos 7.2 master 192.168.121.101node-1 192.168.121.134node-2 192.168.121.135 Kubernetes集群组件:– et ...
- Geoserver发布强制显示标签处理
TextSymbolizer 增加如下配置: <!-- 标签重叠也显示 --> <VendorOption name="conflictResolution" ...
- HTML5+规范:Geolocation(管理设备位置信息) 定位
Geolocation模块管理设备位置信息,用于获取地理位置信息,如经度.纬度等.通过plus.geolocation可获取设备位置管理对象.虽然W3C已经提供标准API获取位置信息,但在某些平台存在 ...
- Etcd 使用入门
etcd简介 etcd是CoreOS团队于2013年6月发起的开源项目,它的目标是构建一个高可用的分布式键值(key-value)数据库.etcd内部采用raft协议作为一致性算法,etcd基于Go语 ...
- Hive学习笔记(三)—— 数据类型
Hive的基本使用(一)--数据类型 1. Hive的基本数据类型 Hive数据类型 Java数据类型 长度 例子 TINYINT byte 1byte有符号整数 20 SMALINT short 2 ...
- php中的htmlspecialchars_decode()函数
htmlspecialchars_decode() 函数把一些预定义的 HTML 实体转换为字符. <?php $str = "This is some <b>bold&l ...