Preloader
Skip to content
How to set or change the hostname on a Linux server

How to set or change the hostname on a Linux server

This article is published in Vietnamese.

How to set or change the hostname on a Linux server

```

$ hostname

Photue-Server-1

```

Nếu muốn thay đổi hostname đó, chỉ cần chạy lệnh :

```

$ hostname NEW_HOSTNAME

```

Tất nhiên bạn cần thay thế “NEW_HOSTNAME” bằng hostname mà bạn muốn đặt. Lệnh này chỉ thay đổi hostname của server tạm thời, server sẽ tự động khôi phục lại hostname ban đầu sau khi reboot .

Thay đổi hostname vĩnh viễn trên Linux

Các phiên bản mới của các bản phân phối Linux như Ubuntu, Debian, CentOS, Fedora, RedHat… hiện nay đều đi kèm systemd, một trình quản lý system và các service cung cấp lệnh hostnamectl để quản lý hostname trong Linux.

Để đặt hostname cho server hỗ trợ systemd ta có thể sử dụng lệnh:

```

$ sudo hostnamectl set-hostname NEW_HOSTNAME

```

Đối với các bản phân phối Linux cũ hơn, còn sử dụng SysVinit (hay init), có thể thay đổi hostname của chúng bằng cách thay đổi trong file cấu hình hostname :

```

# vi /etc/hosname

```

Sau đó khởi động lại hostname:

```

# /etc/init.d/hostname restart

```

Đối với các hệ thống RHEL/CentOS sử dụng init cũ, hostname có thể được thay đổi bằng cách thay đổi cấu hình network:

```

# vi /etc/sysconfig/network

```

Ví dụ :

```

NETWORKING=yes

HOSTNAME="Photue-Server"

GATEWAY="192.168.0.1"

GATEWAYDEV="eth0"

FORWARD_IPV4="yes"

Share:
Phạm Thanh Long
Author

Phạm Thanh Long

Pho Tue SoftWare Solutions JSC là Nhà Cung cấp dịch Trung Tâm Dữ Liệu, Điện Toán Đám Mây Và Phát Triển Phần Mềm Hàng Đầu Việt Nam. Hệ Thống Data Center Đáp Ứng Mọi Nhu Cầu Với Kết Nối Internet Nhanh, Băng Thông Lớn, Uptime Lên Đến 99,99% Theo Tiêu Chuẩn TIER III-TIA 942.

Leave a comment

Your email address will not be published. Required fields are marked *

Trusted by more than 85,000 customers in Vietnam and worldwide

Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo

Technology partners we build with

Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo

Resources for building your digital infrastructure

Technical support

Start your deployment with a dedicated Pho Tue Software team.

Latest updates

Service announcements, in-depth analysis and ecosystem activity.

International certifications and security standards

Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard

Member of regional and national internet registries

Internet registry
Internet registry
Internet registry
Internet registry
Internet registry
Internet registry
Internet registry
Internet registry
Internet registry
Internet registry
Internet registry
We use cookies to improve your experience on this website. Privacy policy