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面向对象之多态、多态性
阅读目录 一 多态 多态指的是一类事物有多种形态 动物有多种形态:人,狗,猪 import abc class Animal(metaclass=abc.ABCMeta): #同一类事物:动物 @ab ...
- gRPC-拦截器简单使用
概述 gRPC作为通用RPC框架,内置了拦截器功能.包括服务器端的拦截器和客户端拦截器,使用上大同小异.主要作用是在rpc调用的前后进行额外处理. 从客户端角度讲,可以在请求发起前,截取到请求参数并修 ...
- cocos creator图片渲染问题!
问题:游戏项目需要添加一个开场剧情(); 第一时间使用了cc.component.scheduleOnce (), 里面的回调函数为 cc.loader.loadRes(). 进入游戏时,渲染主场景后 ...
- c# 基于WebApi的快速开发框架FastFramework
一.框架简介 此框架是针对于webapi进行开发,项目分层是基于ABP框架的分层,更好的抽离业务逻辑关系,ABP是基于EF做数据访问层,本人个人比较喜欢Dapper,就把数据访问层封装成了Dapper ...
- streamController
- Linux 命令:ls
1. ls命令: list的缩写,查看目录中的文件 ls [选项] [目录名] dos 命令: dir 2. 常用参数: -a, –all 列出目录下的所有文件,包括以 . 开头的隐含文件 -A 同- ...
- git拉取单个子目录
初始化一个目录cron(需要拉取的的是code下的cron目录) git init cron 进入目录cd cron/ git remote add -f code ssh://git@192.168 ...
- 内核加载错误module license
出现如下错误: module_name: Unknown symbol "symbol_name" tail /var/log/messages查看具体错误 出现如下错误: Unk ...
- 如何在SAP Cloud Platform上进行第一个integration flow开发
登录SAP Cloud Platform integration tenant,点击Edit图标: 创建一个新的Content package: 保存content package后,点击artifa ...
- 使用Prometheus针对自己的服务器采集自定义的参数
用一个简单的例子来说明. 我用express和http搭了一个最简单的服务器,监听在8081端口上. 在metrics endpoint上,我会打印出这个服务器从启动至今,服务了多少次请求.这里我只是 ...