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:
|
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. ...
随机推荐
- ubuntu安装shadow socks-qt5
Ubuntu16安装shadow socks-qt5 在Ubuntu下也是有GUI客户端,怎么安装请看下面: 首先,针对Ubuntu16的版本可以直接这么安装: .$ sudo add-apt-rep ...
- C#基础—数组
C#基础之数组 1. 数组的定义与初始化 一维数组: (1) int [] A = new int[4]{ 0,1,2,3}; (2) int[] B ...
- 实战Go内存泄露【转】
最近解决了我们项目中的一个内存泄露问题,事实再次证明pprof是一个好工具,但掌握好工具的正确用法,才能发挥好工具的威力,不然就算你手里有屠龙刀,也成不了天下第一,本文就是带你用pprof定位内存泄露 ...
- 在Java中如何设置一个定时任务,在每天的一个时间点自动执行一个特定的程序
Quartz定时机制 首先导入jar包到程序内 quartz-all-1.6.0.jar 然后创建一个XML TimeConfig.xml 名字可以自己定义 <?xml version=&quo ...
- Charles配置https
1. 安装Charles ,破解将Charles.jar 覆盖安装路径的\lib 中的文件 2. 查看本机IP 3. 设置手机代理 4. 设置: 5. 手机安装证书 手机浏览器输入网址:chls.pr ...
- go install -v github.com/gopherjs/gopherjs报错提示go cannot find package "golang.org/x/crypto/ssh/terminal" 解决方案
1前言 方法一:go get 方法二: github clone 2 方法方法一:go get go get golang.org/x/crypto/ssh/terminal 但是这种方法容易被墙,出 ...
- centos7下使用x11远程带窗口安装Oracle
目录 centos7静默安装oracle11gR2 文章目录 一.检查硬件要求 1.内存要求: 2.安装包: 二.环境准备 1.安装必要的工具 2.关闭防火墙 3.关闭Selinux 4.安装Orac ...
- 两种方式测试 GNS3 环境
GNS3已经部署好了,怎么测试环境呢?两种方式,一是使用自带的VPC连接交换机互联互通,二是配合VMware连接GNS3中的交换机互联互通. 自带 VPC 测试 使用两台VPC与一台二层交换机相连,测 ...
- centos7 ipython安装
##下载yum源(Centos 7 为例)[root@localhost ~]# wget http://mirror.centos.org/centos/7/extras/x86_64/Packag ...
- CSS中px,em,rem,pt的区别及四者换算?
本文章重要说明px,em,rem,pt的区别以及四者之间的换算. em单位有如下特点 1. em的值并不是固定的; 2. em会继承父级元素的字体大小. 我们在写CSS的时候如果要用em为单位,需要注 ...