What command always generates the same UUID through /proc/sys/kernel












1















Running the following command generates different random output on each execution (which is expected, considering that random is in the path):



cat /proc/sys/kernel/random/uuid



Is there any way to modify the path so that it results in a static (not random) UUID on each call (return the same thing on each request/execution instead of being random)?










share|improve this question




















  • 4





    This doesn't make sense much. A uuid (Universal Unique IDentifier) is meant to be unique among system's generated uuid's as well as global known uuid's. If you want to refer to the same uuid you generate, just use mystaticuuid=$(uuidgen) and then call it using echo "$mystaticuuid"

    – Valentin Bajrami
    Mar 8 '17 at 9:48
















1















Running the following command generates different random output on each execution (which is expected, considering that random is in the path):



cat /proc/sys/kernel/random/uuid



Is there any way to modify the path so that it results in a static (not random) UUID on each call (return the same thing on each request/execution instead of being random)?










share|improve this question




















  • 4





    This doesn't make sense much. A uuid (Universal Unique IDentifier) is meant to be unique among system's generated uuid's as well as global known uuid's. If you want to refer to the same uuid you generate, just use mystaticuuid=$(uuidgen) and then call it using echo "$mystaticuuid"

    – Valentin Bajrami
    Mar 8 '17 at 9:48














1












1








1








Running the following command generates different random output on each execution (which is expected, considering that random is in the path):



cat /proc/sys/kernel/random/uuid



Is there any way to modify the path so that it results in a static (not random) UUID on each call (return the same thing on each request/execution instead of being random)?










share|improve this question
















Running the following command generates different random output on each execution (which is expected, considering that random is in the path):



cat /proc/sys/kernel/random/uuid



Is there any way to modify the path so that it results in a static (not random) UUID on each call (return the same thing on each request/execution instead of being random)?







proc uuid






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 8 '17 at 9:41









schaiba

5,53912229




5,53912229










asked Mar 8 '17 at 9:39









Agi HammerthiefAgi Hammerthief

379120




379120








  • 4





    This doesn't make sense much. A uuid (Universal Unique IDentifier) is meant to be unique among system's generated uuid's as well as global known uuid's. If you want to refer to the same uuid you generate, just use mystaticuuid=$(uuidgen) and then call it using echo "$mystaticuuid"

    – Valentin Bajrami
    Mar 8 '17 at 9:48














  • 4





    This doesn't make sense much. A uuid (Universal Unique IDentifier) is meant to be unique among system's generated uuid's as well as global known uuid's. If you want to refer to the same uuid you generate, just use mystaticuuid=$(uuidgen) and then call it using echo "$mystaticuuid"

    – Valentin Bajrami
    Mar 8 '17 at 9:48








4




4





This doesn't make sense much. A uuid (Universal Unique IDentifier) is meant to be unique among system's generated uuid's as well as global known uuid's. If you want to refer to the same uuid you generate, just use mystaticuuid=$(uuidgen) and then call it using echo "$mystaticuuid"

– Valentin Bajrami
Mar 8 '17 at 9:48





This doesn't make sense much. A uuid (Universal Unique IDentifier) is meant to be unique among system's generated uuid's as well as global known uuid's. If you want to refer to the same uuid you generate, just use mystaticuuid=$(uuidgen) and then call it using echo "$mystaticuuid"

– Valentin Bajrami
Mar 8 '17 at 9:48










2 Answers
2






active

oldest

votes


















4














You asked




Is there any way to modify the path so that it results in a static (not random) UUID on each call




And the answer to this is "yes, definitely".



If you prepare the environment like this:



cat /proc/sys/kernel/random/uuid >/tmp/uuid


You can modify the path to get a static UUID on each call, like this



cat /tmp/uuid





share|improve this answer
























  • Well, that's obvious, I suppose. (I blame lack of sleep for not thinking that through.)

    – Agi Hammerthief
    Mar 8 '17 at 10:49






  • 1





    @Agi what are you actually trying to achieve?

    – roaima
    Mar 8 '17 at 11:16











  • What I actually want to do is create a unique ID for a machine running GNU/Linux, thinking that running a slight adaptation of /proc/sys/kernel/random/uuid would be the way to go. On Windows, I can run wmic DISKDRIVE get SerialNumber and query the registry for the value of HKLMSoftwareMicrosoftCryptographyMachineGuid to get values I can work with. I was wondering if I could achieve something similar with GNU/Linux (other than getting the HWAddrs of all NICs in the machine and hashing them, as I have seen suggested). However, I'll ask a separate question for that.

    – Agi Hammerthief
    Mar 8 '17 at 12:39













  • I have some existing Java software that uses a Windows-specific DLL to retrieve hardware information and generate a hashed UID for the machine on which it runs (implementation details of which are known to me). I'm trying to port it to GNU/Linux and the licensing is what prevents me from porting it. (The output doesn't have to be the same on both platforms, but it would be advantageous if it is.)

    – Agi Hammerthief
    Mar 8 '17 at 12:49








  • 2





    @AgiHammerthief take a look at generate consistent machine unique ID

    – roaima
    Mar 8 '17 at 13:42



















1














Having recently needed to build some licensing functionality into an application (the problem I was trying to solve when first posting this question), I found that it's possible to obtain a static UUID from one of the following files:



/etc/machine-id  # preferred
/var/lib/dbus/machine-id # Usually a symlink to /etc/machine-id
/var/db/dbus/machine-id # usually a symlink/alternative to /var/lib/dbus/machine-id
/proc/sys/kernel/random/uuid # Will vary on each invocation, so save output to another file
# (as per roaima's answer).


In the above list of files, they're listed from most preferred to least preferred.






share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f349952%2fwhat-command-always-generates-the-same-uuid-through-proc-sys-kernel%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    4














    You asked




    Is there any way to modify the path so that it results in a static (not random) UUID on each call




    And the answer to this is "yes, definitely".



    If you prepare the environment like this:



    cat /proc/sys/kernel/random/uuid >/tmp/uuid


    You can modify the path to get a static UUID on each call, like this



    cat /tmp/uuid





    share|improve this answer
























    • Well, that's obvious, I suppose. (I blame lack of sleep for not thinking that through.)

      – Agi Hammerthief
      Mar 8 '17 at 10:49






    • 1





      @Agi what are you actually trying to achieve?

      – roaima
      Mar 8 '17 at 11:16











    • What I actually want to do is create a unique ID for a machine running GNU/Linux, thinking that running a slight adaptation of /proc/sys/kernel/random/uuid would be the way to go. On Windows, I can run wmic DISKDRIVE get SerialNumber and query the registry for the value of HKLMSoftwareMicrosoftCryptographyMachineGuid to get values I can work with. I was wondering if I could achieve something similar with GNU/Linux (other than getting the HWAddrs of all NICs in the machine and hashing them, as I have seen suggested). However, I'll ask a separate question for that.

      – Agi Hammerthief
      Mar 8 '17 at 12:39













    • I have some existing Java software that uses a Windows-specific DLL to retrieve hardware information and generate a hashed UID for the machine on which it runs (implementation details of which are known to me). I'm trying to port it to GNU/Linux and the licensing is what prevents me from porting it. (The output doesn't have to be the same on both platforms, but it would be advantageous if it is.)

      – Agi Hammerthief
      Mar 8 '17 at 12:49








    • 2





      @AgiHammerthief take a look at generate consistent machine unique ID

      – roaima
      Mar 8 '17 at 13:42
















    4














    You asked




    Is there any way to modify the path so that it results in a static (not random) UUID on each call




    And the answer to this is "yes, definitely".



    If you prepare the environment like this:



    cat /proc/sys/kernel/random/uuid >/tmp/uuid


    You can modify the path to get a static UUID on each call, like this



    cat /tmp/uuid





    share|improve this answer
























    • Well, that's obvious, I suppose. (I blame lack of sleep for not thinking that through.)

      – Agi Hammerthief
      Mar 8 '17 at 10:49






    • 1





      @Agi what are you actually trying to achieve?

      – roaima
      Mar 8 '17 at 11:16











    • What I actually want to do is create a unique ID for a machine running GNU/Linux, thinking that running a slight adaptation of /proc/sys/kernel/random/uuid would be the way to go. On Windows, I can run wmic DISKDRIVE get SerialNumber and query the registry for the value of HKLMSoftwareMicrosoftCryptographyMachineGuid to get values I can work with. I was wondering if I could achieve something similar with GNU/Linux (other than getting the HWAddrs of all NICs in the machine and hashing them, as I have seen suggested). However, I'll ask a separate question for that.

      – Agi Hammerthief
      Mar 8 '17 at 12:39













    • I have some existing Java software that uses a Windows-specific DLL to retrieve hardware information and generate a hashed UID for the machine on which it runs (implementation details of which are known to me). I'm trying to port it to GNU/Linux and the licensing is what prevents me from porting it. (The output doesn't have to be the same on both platforms, but it would be advantageous if it is.)

      – Agi Hammerthief
      Mar 8 '17 at 12:49








    • 2





      @AgiHammerthief take a look at generate consistent machine unique ID

      – roaima
      Mar 8 '17 at 13:42














    4












    4








    4







    You asked




    Is there any way to modify the path so that it results in a static (not random) UUID on each call




    And the answer to this is "yes, definitely".



    If you prepare the environment like this:



    cat /proc/sys/kernel/random/uuid >/tmp/uuid


    You can modify the path to get a static UUID on each call, like this



    cat /tmp/uuid





    share|improve this answer













    You asked




    Is there any way to modify the path so that it results in a static (not random) UUID on each call




    And the answer to this is "yes, definitely".



    If you prepare the environment like this:



    cat /proc/sys/kernel/random/uuid >/tmp/uuid


    You can modify the path to get a static UUID on each call, like this



    cat /tmp/uuid






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Mar 8 '17 at 9:43









    roaimaroaima

    44.7k655121




    44.7k655121













    • Well, that's obvious, I suppose. (I blame lack of sleep for not thinking that through.)

      – Agi Hammerthief
      Mar 8 '17 at 10:49






    • 1





      @Agi what are you actually trying to achieve?

      – roaima
      Mar 8 '17 at 11:16











    • What I actually want to do is create a unique ID for a machine running GNU/Linux, thinking that running a slight adaptation of /proc/sys/kernel/random/uuid would be the way to go. On Windows, I can run wmic DISKDRIVE get SerialNumber and query the registry for the value of HKLMSoftwareMicrosoftCryptographyMachineGuid to get values I can work with. I was wondering if I could achieve something similar with GNU/Linux (other than getting the HWAddrs of all NICs in the machine and hashing them, as I have seen suggested). However, I'll ask a separate question for that.

      – Agi Hammerthief
      Mar 8 '17 at 12:39













    • I have some existing Java software that uses a Windows-specific DLL to retrieve hardware information and generate a hashed UID for the machine on which it runs (implementation details of which are known to me). I'm trying to port it to GNU/Linux and the licensing is what prevents me from porting it. (The output doesn't have to be the same on both platforms, but it would be advantageous if it is.)

      – Agi Hammerthief
      Mar 8 '17 at 12:49








    • 2





      @AgiHammerthief take a look at generate consistent machine unique ID

      – roaima
      Mar 8 '17 at 13:42



















    • Well, that's obvious, I suppose. (I blame lack of sleep for not thinking that through.)

      – Agi Hammerthief
      Mar 8 '17 at 10:49






    • 1





      @Agi what are you actually trying to achieve?

      – roaima
      Mar 8 '17 at 11:16











    • What I actually want to do is create a unique ID for a machine running GNU/Linux, thinking that running a slight adaptation of /proc/sys/kernel/random/uuid would be the way to go. On Windows, I can run wmic DISKDRIVE get SerialNumber and query the registry for the value of HKLMSoftwareMicrosoftCryptographyMachineGuid to get values I can work with. I was wondering if I could achieve something similar with GNU/Linux (other than getting the HWAddrs of all NICs in the machine and hashing them, as I have seen suggested). However, I'll ask a separate question for that.

      – Agi Hammerthief
      Mar 8 '17 at 12:39













    • I have some existing Java software that uses a Windows-specific DLL to retrieve hardware information and generate a hashed UID for the machine on which it runs (implementation details of which are known to me). I'm trying to port it to GNU/Linux and the licensing is what prevents me from porting it. (The output doesn't have to be the same on both platforms, but it would be advantageous if it is.)

      – Agi Hammerthief
      Mar 8 '17 at 12:49








    • 2





      @AgiHammerthief take a look at generate consistent machine unique ID

      – roaima
      Mar 8 '17 at 13:42

















    Well, that's obvious, I suppose. (I blame lack of sleep for not thinking that through.)

    – Agi Hammerthief
    Mar 8 '17 at 10:49





    Well, that's obvious, I suppose. (I blame lack of sleep for not thinking that through.)

    – Agi Hammerthief
    Mar 8 '17 at 10:49




    1




    1





    @Agi what are you actually trying to achieve?

    – roaima
    Mar 8 '17 at 11:16





    @Agi what are you actually trying to achieve?

    – roaima
    Mar 8 '17 at 11:16













    What I actually want to do is create a unique ID for a machine running GNU/Linux, thinking that running a slight adaptation of /proc/sys/kernel/random/uuid would be the way to go. On Windows, I can run wmic DISKDRIVE get SerialNumber and query the registry for the value of HKLMSoftwareMicrosoftCryptographyMachineGuid to get values I can work with. I was wondering if I could achieve something similar with GNU/Linux (other than getting the HWAddrs of all NICs in the machine and hashing them, as I have seen suggested). However, I'll ask a separate question for that.

    – Agi Hammerthief
    Mar 8 '17 at 12:39







    What I actually want to do is create a unique ID for a machine running GNU/Linux, thinking that running a slight adaptation of /proc/sys/kernel/random/uuid would be the way to go. On Windows, I can run wmic DISKDRIVE get SerialNumber and query the registry for the value of HKLMSoftwareMicrosoftCryptographyMachineGuid to get values I can work with. I was wondering if I could achieve something similar with GNU/Linux (other than getting the HWAddrs of all NICs in the machine and hashing them, as I have seen suggested). However, I'll ask a separate question for that.

    – Agi Hammerthief
    Mar 8 '17 at 12:39















    I have some existing Java software that uses a Windows-specific DLL to retrieve hardware information and generate a hashed UID for the machine on which it runs (implementation details of which are known to me). I'm trying to port it to GNU/Linux and the licensing is what prevents me from porting it. (The output doesn't have to be the same on both platforms, but it would be advantageous if it is.)

    – Agi Hammerthief
    Mar 8 '17 at 12:49







    I have some existing Java software that uses a Windows-specific DLL to retrieve hardware information and generate a hashed UID for the machine on which it runs (implementation details of which are known to me). I'm trying to port it to GNU/Linux and the licensing is what prevents me from porting it. (The output doesn't have to be the same on both platforms, but it would be advantageous if it is.)

    – Agi Hammerthief
    Mar 8 '17 at 12:49






    2




    2





    @AgiHammerthief take a look at generate consistent machine unique ID

    – roaima
    Mar 8 '17 at 13:42





    @AgiHammerthief take a look at generate consistent machine unique ID

    – roaima
    Mar 8 '17 at 13:42













    1














    Having recently needed to build some licensing functionality into an application (the problem I was trying to solve when first posting this question), I found that it's possible to obtain a static UUID from one of the following files:



    /etc/machine-id  # preferred
    /var/lib/dbus/machine-id # Usually a symlink to /etc/machine-id
    /var/db/dbus/machine-id # usually a symlink/alternative to /var/lib/dbus/machine-id
    /proc/sys/kernel/random/uuid # Will vary on each invocation, so save output to another file
    # (as per roaima's answer).


    In the above list of files, they're listed from most preferred to least preferred.






    share|improve this answer




























      1














      Having recently needed to build some licensing functionality into an application (the problem I was trying to solve when first posting this question), I found that it's possible to obtain a static UUID from one of the following files:



      /etc/machine-id  # preferred
      /var/lib/dbus/machine-id # Usually a symlink to /etc/machine-id
      /var/db/dbus/machine-id # usually a symlink/alternative to /var/lib/dbus/machine-id
      /proc/sys/kernel/random/uuid # Will vary on each invocation, so save output to another file
      # (as per roaima's answer).


      In the above list of files, they're listed from most preferred to least preferred.






      share|improve this answer


























        1












        1








        1







        Having recently needed to build some licensing functionality into an application (the problem I was trying to solve when first posting this question), I found that it's possible to obtain a static UUID from one of the following files:



        /etc/machine-id  # preferred
        /var/lib/dbus/machine-id # Usually a symlink to /etc/machine-id
        /var/db/dbus/machine-id # usually a symlink/alternative to /var/lib/dbus/machine-id
        /proc/sys/kernel/random/uuid # Will vary on each invocation, so save output to another file
        # (as per roaima's answer).


        In the above list of files, they're listed from most preferred to least preferred.






        share|improve this answer













        Having recently needed to build some licensing functionality into an application (the problem I was trying to solve when first posting this question), I found that it's possible to obtain a static UUID from one of the following files:



        /etc/machine-id  # preferred
        /var/lib/dbus/machine-id # Usually a symlink to /etc/machine-id
        /var/db/dbus/machine-id # usually a symlink/alternative to /var/lib/dbus/machine-id
        /proc/sys/kernel/random/uuid # Will vary on each invocation, so save output to another file
        # (as per roaima's answer).


        In the above list of files, they're listed from most preferred to least preferred.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Feb 4 at 14:33









        Agi HammerthiefAgi Hammerthief

        379120




        379120






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f349952%2fwhat-command-always-generates-the-same-uuid-through-proc-sys-kernel%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            How to make a Squid Proxy server?

            第一次世界大戦

            Touch on Surface Book