hostid เป็นคำสั่งที่ไว้ใช้ดู id ของเครื่อง Linux โดยเมื่อติดตั้ง Linux เสร็จระบบจะสร้าง host id ขึ้นมาและจะไม่ซ้ำกับ id เดิมในกรณีที่ติดตั้งใหม่ ดังนั้นโปรแกรมที่มีลิขสิทธิ์ส่วนมากจะอ้างอิง license กับ host id เพื่อป้องกัน…

การดู hostid สามารถใช้คำสั่ง hostid ดังตัวอย่างด้านล่าง

[root@Ezylinux ~]# hostid
007f0101


การแก้ไข hostid สามารถทำได้ดังนี้
ขั้นแรกต้องมี gcc (compiler) ก่อน ถ้าไม่มี ใช้คำสั่ง

[root@Ezylinux ~]# apt-get install gcc*  //สำหรับสาย debain

หรือ

[root@Ezylinux ~]# yum install gcc*      //สำหรับสาย red hat

ต่อมาสร้างไฟล์ชื่อ sethostid.c ใส่ code ข้างล่างลงไป และเปลี่ยนตรง sethostid ให้เป็น hostid ที่ต้องการ

#include
#include 

int main() {
long id,res;
id = gethostid();
printf("current hostid is: %x\n",id);
res = sethostid(0x11223344);  // แก้ไขค่า 11223344 เป็นค่าที่ต้องการ
if (res == 0) printf("if result is zero - success! (%d) \n",res);
id = gethostid();
printf("current hostid is: %x ;-PPPppppp\n",id);
}

จากนั้นให้ compile ด้วยคำสั่ง

[root@Ezylinux ~]# gcc -o sethostid sethostid.c

เมื่อ compile เสร็จจะได้ไฟลฺ์ชื่อ sethostid มา แล้วใช้คำสั่งด้านล่างเพื่อรันโปรแกรม

[root@Ezylinux ~]# ./sethostid