-1

I'm trying to get unique value from Linux server, something like hardware id, for non-root user I tried to use the mac address of the network interface but in the venet0 interface (virtual network interface) there is no mac address and the output of the ip addr command is:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: venet0: <BROADCAST,POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN
    link/void
    inet 127.0.0.1/32 scope host venet0
    inet x.x.x.x/32 brd x.x.x.x scope global venet0:0
    inet6 ::2/128 scope global
       valid_lft forever preferred_lft foreve

so what is the best way to do that for non-root user and by using build in Linux command that's work on all Linux distributions?

Mr.mb
  • 82
  • 4
  • There may not be a unique hardware ID if you're using a virtual environment. – Barmar Sep 06 '19 at 08:19
  • [Is there a UUID type of value in Linux that can uniquely identify an instance of a VM?](https://stackoverflow.com/q/8722050/608639), [Best way to get machine id on Linux?](https://stackoverflow.com/q/10152762/608639), [Generate consistent machine unique ID](https://unix.stackexchange.com/q/144812), etc. – jww Sep 06 '19 at 23:50

1 Answers1

0

You could try to get the CPU ID, or better the general computer UUID:

$ sudo dmidecode | grep UUID

See the linked thread for more options. As you seem to work in a virtualized environment, check that they are actually unique. Perhaps also incorporate the hostname.

Murphy
  • 3,229
  • 3
  • 20
  • 35