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. ...
随机推荐
- 基于FPGA Manager的Zynq PL程序写入方案
本文主要描述了如何在Linux系统启动以后,在线将bitstream文件更新到ZYNQ PL的过程及方法.相关内容主要译自xilinx-wiki,其中官网给出了两种方法,分别为Device Tree ...
- appium 方法整理
1.contexts contexts(self): Returns the contexts within the current session. 返回当前会话中的上下文,使用后可 ...
- Oracle各种连接函数总结
1.前言 Oracle可用连接函数会介绍以下几个 Oracle列转行函数 Listagg() strcat() wmsys.wm_concat() 2.Oracle列转行函数 Listagg() 2. ...
- spring使用JUnit测试,@Autowired无法注入原因
在测试类上加入配置文件 代码如下 @RunWith(SpringJUnit4ClassRunner.class)// SpringJUnit支持,由此引入Spring-Test框架支持! @Cont ...
- js的splice和delete
例如有一个数组是 :var textArr = ['a','b','c','d']; 这时我想删除这个数组中的b元素: 方法一:delete 删除数组 delete textArr[1] 结果为: ...
- java之mybatis之一对多关联映射
1.在一对多的关联映射中,表结构如下 2.实体类结构 User.java public class User implements Serializable{ private int id; priv ...
- Linux中解压、压缩 ZIP文件
解压 unzip -o -d /home/v-gazh myfile.zip # 把myfile.zip文件解压到 /home/v-gazh/ # -o:不提示的情况下覆盖文件: # -d:-d /h ...
- Python进阶----计算机基础知识(操作系统多道技术),进程概念, 并发概念,并行概念,多进程实现
Python进阶----计算机基础知识(操作系统多道技术),进程概念, 并发概念,并行概念,多进程实现 一丶进程基础知识 什么是程序: 程序就是一堆文件 什么是进程: 进程就是一个正在 ...
- pathlib的使用
目录 一. Python2与Python3的路径处理的对比 二. pathlib的几个使用示例 1. 最简单的使用 2. 追加路径到Python的sys.path中 3. 生成目录树的技巧 4. 递归 ...
- vue动态加载不同的组件(分内部和外部组件)
<!DOCTYPE html> <html> <head> <title> hello world vue </title> <met ...