• Ubuntu
  • Python
  • Windows
  • VirtualBox
  • Git
  • Docker
  • Windows
Chat
Writy.
No Result
View All Result
My Account
Writy.
No Result
View All Result
sxi
No Result
View All Result

Home Linux change my hostname / computer system name

Linux change my hostname / computer system name

SXI ADMIN by SXI ADMIN
September 8, 2019
in Blog
Reading Time: 4 mins read
A A
0
Share on FacebookShare on Twitter

I am using Ubuntu Linux. How do I change my hostname or the machine name using the command line option?

You need to use hostname command or hostnamectrl command on modern Linux distro. It is used to either set or display the current host or domain name of the system. This name is used by many of the networking programs to identify the Linux based machine. The following instructions should work on both Debian and Ubuntu Linux systems or any Linux distro if you are using hostnamectrl.

How to display current hostname

Just type hostname command to print the name of the system on screen:
$ hostname
Sample outputs:

viveks-desktop

Change the Linux hostname

Set hostname to desktop.nixcraft.com:
# hostname desktop.nixcraft.com
# hostname

Sample outputs:

desktop.nixcraft.com

Change hostname permanently on a Debian/Ubuntu Linux

You need to edit a file called /etc/hostname:
# vi /etc/hostname
Set new hostname:

desktop.nixcraft.com

Save and close the file. You need to reboot the system or run any one of the following command:
# /etc/init.d/hostname.sh start
OR
# invoke-rc.d hostname.sh start

Linux change hostname using hostnamectl command (systemd only)

Most modern Linux distribution comes with systemd. If you are using systemd based distro try hostnamectl command.

Query hostname with hostnamectl

Let us print out current hostname:
$ hostnamectl

Change hostname with hostnamectl

The syntax is as follows to set hostname to ‘viveks-laptop’:
$ hostnamectl set-hostname 'viveks-laptop'
Sample outputs:

Fig.01: hostnamectl in action on a Linux based system

Set the deployment environment description

ENVIRONMENT must be a single word without any control characters. One of the following is suggested: “development”, “integration”, “staging”, “production”. The syntax is:
$ hostnamectl set-deployment ENVIRONMENT
$ hostnamectl set-deployment production

How to set the location string for the system, if it is known

The syntax is:
$ hostnamectl set-location LOCATION
$ hostnamectl set-location "NYC Home"
$ hostnamectl set-location "DC 2, right rack, 2nd shelf"

A note about an RHEL (Red hat) / CentOS / Fedora Linux users

If you are using CentOS or Fedora or Redhat (RHEL) Linux, see this FAQ.

This entry is 3 of 15 in the Linux/Unix Set hostname Tutorial series. Keep reading the rest of the series:

  1. Ubuntu Linux Change Hostname (computer name)
  2. Debian Linux: Change Hostname / Computer Name Permanently
  3. Linux change my hostname / computer system name
  4. Linux Change Hostname
  5. RHEL / Centos Linux 7: Change and Set Hostname Command
  6. OpenBSD Change Hostname
  7. CentOS Linux 5/6 Change Hostname Command
  8. Linux setting hostname and domain name of my server
  9. FreeBSD Change Hostname without reboot
  10. SuSe Linux Change Hostname without reboot
  11. How to set the hostname on Fedora Linux
  12. Ubuntu 18.04 LTS change hostname permanently
  13. Ubuntu set hostname permanently (computer name) command
  14. OpenSUSE Linux set hostname permanently (computer name) command
  15. RHEL 8 Linux set hostname permanently (computer name) command

Share on Facebook Twitter

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Total
0
Shares
Share 0
Tweet 0
Pin it 0
Share 0
Tags: Blog
SXI ADMIN

SXI ADMIN

Related Stories

Hostbillapp Enterprise v2022-05-02 Nulled 2022 and 2019 Theme License Hostbill 2022 nulled

Hostbillapp Enterprise v2022-05-02 Nulled 2022 and 2019 Theme License Hostbill 2022 nulled

by SXI ADMIN
May 17, 2022
0

Demo : https://bitdom.org/ All modue : PowerDNS, SolusVM, Proxmox, OnApp, Openstack, Cloudstack, vSphere, Virtualizor Contact : https://t.me/sxillc Enable auto-charge by...

Link download Kali Linux 2021.2 torrent live cd and Installer

Link download Kali Linux 2021.2 torrent live cd and Installer

by SXI ADMIN
June 3, 2021
0

Live Run Kali Linux https://cdimage.kali.org/kali-2021.2/kali-linux-2021.2-live-amd64.iso Installer 4GB https://cdimage.kali.org/kali-2021.2/kali-linux-2021.2-installer-amd64.iso and full all : https://www.kali.org/get-kali/#kali-platforms

WHMCS 8.2 Beta Nulled

CentOS / RHEL 7 Restart / Stop / Start Networking Command

by SXI ADMIN
May 22, 2021
0

Say hello to systemctl command Use this command to control the systemd system and act as a service manager. CentOS...

WHMCS 8.2 Beta Nulled

WHMCS 8.2 Beta Nulled

by SXI ADMIN
May 20, 2021
0

We're excited to announce the beta release of WHMCS 8.2. Be among the first to try out the new features...

You have a Great  Business Idea?

How to create CentOS 7 and CentOS 8 bootable USB drive in Windows Step

by SXI ADMIN
May 19, 2021
0

Most of tools available to create bootable USB drive doesn’t worked on CentOS 7. Problems like unable to boot, unable to...

Wowza Streaming Engine 4.8.12+1 Crack

by SXI ADMIN
August 24, 2021
0

Tested and working in Windows and Linux. Exclusively for the forum, exactly one day before I post it on the...

Load More
Next Post
Link download Kali Linux 2020.1 (ISO + Torrent)

Link download Kali Linux 2020.1 (ISO + Torrent)

Popular Story

  • EMEDITOR PROFESSIONAL Full Key V11~V19

    646 shares
    Share 258 Tweet 162
  • Plesk Obsidian Lifetime license Key Version 18.0.15

    646 shares
    Share 258 Tweet 162
  • Plesk Onyx + Obsidian 18 Web Host Edition Nulled/Crack

    615 shares
    Share 246 Tweet 154
  • How To Start/Stop/Restart Cron Service In Linux Centos 7

    610 shares
    Share 244 Tweet 153
  • Download Windows Templates for Virtualizor KVM Windows server 2008,2012,2016,2019

    608 shares
    Share 243 Tweet 152
SXI.IO

© 2022 Vps giá rẻ

Navigate Site

  • Ubuntu
  • Python
  • Windows
  • VirtualBox
  • Git
  • Docker
  • Windows

Follow Us

No Result
View All Result
  • Ubuntu
  • Python
  • Windows
  • VirtualBox
  • Git
  • Docker
  • Windows

© 2022 Vps giá rẻ