Difference between modprobe and sysctl -w in terms of setting system parameters?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
4
down vote

favorite
4












We know that sysctl command can change kernel parameters with :



# sysctl -w kernel.domainname="example.com"


or by directly editing the file in /proc/sys directory. And for persistent changes, the parameters must be written to /etc/sysctl.d/<moduleName>.conf files as:



# echo kernel.domainname="example.com" > /etc/sysctl.d/domainname.conf


However, we can also change the kernel parameters using the modprobe command:



# modprobe kernel domainname="example.com"


And then there's the modprobe.conf file in the /etc/modprobe.d directories, which is present in multiple locations: /etc/modprobe.d and /usr/lib/modprobe.d. It contains multiple .conf files, and the options can be provided in the appropriate conf file for the module as:



options kernel domainname="example.com"


So, what's the difference between each of these methods? Which method should be used under what specific circumstances?







share|improve this question


























    up vote
    4
    down vote

    favorite
    4












    We know that sysctl command can change kernel parameters with :



    # sysctl -w kernel.domainname="example.com"


    or by directly editing the file in /proc/sys directory. And for persistent changes, the parameters must be written to /etc/sysctl.d/<moduleName>.conf files as:



    # echo kernel.domainname="example.com" > /etc/sysctl.d/domainname.conf


    However, we can also change the kernel parameters using the modprobe command:



    # modprobe kernel domainname="example.com"


    And then there's the modprobe.conf file in the /etc/modprobe.d directories, which is present in multiple locations: /etc/modprobe.d and /usr/lib/modprobe.d. It contains multiple .conf files, and the options can be provided in the appropriate conf file for the module as:



    options kernel domainname="example.com"


    So, what's the difference between each of these methods? Which method should be used under what specific circumstances?







    share|improve this question
























      up vote
      4
      down vote

      favorite
      4









      up vote
      4
      down vote

      favorite
      4






      4





      We know that sysctl command can change kernel parameters with :



      # sysctl -w kernel.domainname="example.com"


      or by directly editing the file in /proc/sys directory. And for persistent changes, the parameters must be written to /etc/sysctl.d/<moduleName>.conf files as:



      # echo kernel.domainname="example.com" > /etc/sysctl.d/domainname.conf


      However, we can also change the kernel parameters using the modprobe command:



      # modprobe kernel domainname="example.com"


      And then there's the modprobe.conf file in the /etc/modprobe.d directories, which is present in multiple locations: /etc/modprobe.d and /usr/lib/modprobe.d. It contains multiple .conf files, and the options can be provided in the appropriate conf file for the module as:



      options kernel domainname="example.com"


      So, what's the difference between each of these methods? Which method should be used under what specific circumstances?







      share|improve this question














      We know that sysctl command can change kernel parameters with :



      # sysctl -w kernel.domainname="example.com"


      or by directly editing the file in /proc/sys directory. And for persistent changes, the parameters must be written to /etc/sysctl.d/<moduleName>.conf files as:



      # echo kernel.domainname="example.com" > /etc/sysctl.d/domainname.conf


      However, we can also change the kernel parameters using the modprobe command:



      # modprobe kernel domainname="example.com"


      And then there's the modprobe.conf file in the /etc/modprobe.d directories, which is present in multiple locations: /etc/modprobe.d and /usr/lib/modprobe.d. It contains multiple .conf files, and the options can be provided in the appropriate conf file for the module as:



      options kernel domainname="example.com"


      So, what's the difference between each of these methods? Which method should be used under what specific circumstances?









      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 14 '17 at 8:23

























      asked Dec 14 '17 at 8:17









      Somenath Sinha

      22319




      22319




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          4
          down vote



          accepted










          As far as I know, you can use modprobe to adjust parameters only when the feature in question has been compiled as a module - and you're loading the module in the first place. For setting module parameters persistently, you'll have the /etc/modprobe.d directory. (Generally you should leave /usr/lib/modprobe.d for distribution's default settings - any files in there may get overwritten by package updates.)



          If the module in question has been built into the main kernel, then you must use the <module_name>.<parameter_name>=<value> syntax, typically as a boot option. If the parameter in question is available as a sysctl setting, then you can use the sysctl -w command to adjust it too.



          All the available sysctl parameters are presented under /proc/sys: for example, kernel.domainname is at /proc/sys/kernel/domainname. Not all module parameters are available as sysctls, but some might be.



          If a loadable module has already been loaded, and you wish to change its parameters immediately without unloading it, then you can write the new value to /sys/module/<module_name>/parameters/<parameter_name>. If the module cannot accept dynamic reconfiguration for that parameter, the file will be read-only.



          At least on my system, kernel.domainname is a sysctl parameter for the main kernel, and trying to change it with modprobe won't work:



          # sysctl kernel.domainname
          kernel.domainname = (none)
          # modprobe kernel domainname="example.com"
          modprobe: FATAL: Module kernel not found in directory /lib/modules/<kernel_version>
          # sysctl kernel.domainname
          kernel.domainname = (none)


          In a nutshell: If you are unsure, first look into /proc/sys or the output of sysctl -a: if the parameter you're looking for is not there, it is not a sysctl parameter and is probably a module parameter (or the module that would provide the sysctl is not currently loaded, in which case it's better to set the value as a module parameter anyway - trying to set a sysctl belonging to a module that is not currently loaded will just produce an error).



          Then, find out which module the parameter belongs to. If the module is built into the kernel, you'll probably have to use a boot option; if it is loadable with modprobe (i.e. the respective <module>.ko file exists somewhere in the /lib/modules/<kernel version>/ directory tree), then you can use modprobe and/or /etc/modprobe.d/.






          share|improve this answer






















          • So basically, certain params are editable via modprobe, others via sysctl?? How can i find out which is which??
            – Somenath Sinha
            Dec 14 '17 at 9:15










          • I've edited my answer to hopefully clarify that.
            – telcoM
            Dec 14 '17 at 9:29










          • sysctl -a will also show you all the parameters that can be set with sysctl.
            – Raman Sailopal
            Dec 14 '17 at 9:33










          • That's a good point.
            – telcoM
            Dec 14 '17 at 9:52










          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',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          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%2f410811%2fdifference-between-modprobe-and-sysctl-w-in-terms-of-setting-system-parameters%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          4
          down vote



          accepted










          As far as I know, you can use modprobe to adjust parameters only when the feature in question has been compiled as a module - and you're loading the module in the first place. For setting module parameters persistently, you'll have the /etc/modprobe.d directory. (Generally you should leave /usr/lib/modprobe.d for distribution's default settings - any files in there may get overwritten by package updates.)



          If the module in question has been built into the main kernel, then you must use the <module_name>.<parameter_name>=<value> syntax, typically as a boot option. If the parameter in question is available as a sysctl setting, then you can use the sysctl -w command to adjust it too.



          All the available sysctl parameters are presented under /proc/sys: for example, kernel.domainname is at /proc/sys/kernel/domainname. Not all module parameters are available as sysctls, but some might be.



          If a loadable module has already been loaded, and you wish to change its parameters immediately without unloading it, then you can write the new value to /sys/module/<module_name>/parameters/<parameter_name>. If the module cannot accept dynamic reconfiguration for that parameter, the file will be read-only.



          At least on my system, kernel.domainname is a sysctl parameter for the main kernel, and trying to change it with modprobe won't work:



          # sysctl kernel.domainname
          kernel.domainname = (none)
          # modprobe kernel domainname="example.com"
          modprobe: FATAL: Module kernel not found in directory /lib/modules/<kernel_version>
          # sysctl kernel.domainname
          kernel.domainname = (none)


          In a nutshell: If you are unsure, first look into /proc/sys or the output of sysctl -a: if the parameter you're looking for is not there, it is not a sysctl parameter and is probably a module parameter (or the module that would provide the sysctl is not currently loaded, in which case it's better to set the value as a module parameter anyway - trying to set a sysctl belonging to a module that is not currently loaded will just produce an error).



          Then, find out which module the parameter belongs to. If the module is built into the kernel, you'll probably have to use a boot option; if it is loadable with modprobe (i.e. the respective <module>.ko file exists somewhere in the /lib/modules/<kernel version>/ directory tree), then you can use modprobe and/or /etc/modprobe.d/.






          share|improve this answer






















          • So basically, certain params are editable via modprobe, others via sysctl?? How can i find out which is which??
            – Somenath Sinha
            Dec 14 '17 at 9:15










          • I've edited my answer to hopefully clarify that.
            – telcoM
            Dec 14 '17 at 9:29










          • sysctl -a will also show you all the parameters that can be set with sysctl.
            – Raman Sailopal
            Dec 14 '17 at 9:33










          • That's a good point.
            – telcoM
            Dec 14 '17 at 9:52














          up vote
          4
          down vote



          accepted










          As far as I know, you can use modprobe to adjust parameters only when the feature in question has been compiled as a module - and you're loading the module in the first place. For setting module parameters persistently, you'll have the /etc/modprobe.d directory. (Generally you should leave /usr/lib/modprobe.d for distribution's default settings - any files in there may get overwritten by package updates.)



          If the module in question has been built into the main kernel, then you must use the <module_name>.<parameter_name>=<value> syntax, typically as a boot option. If the parameter in question is available as a sysctl setting, then you can use the sysctl -w command to adjust it too.



          All the available sysctl parameters are presented under /proc/sys: for example, kernel.domainname is at /proc/sys/kernel/domainname. Not all module parameters are available as sysctls, but some might be.



          If a loadable module has already been loaded, and you wish to change its parameters immediately without unloading it, then you can write the new value to /sys/module/<module_name>/parameters/<parameter_name>. If the module cannot accept dynamic reconfiguration for that parameter, the file will be read-only.



          At least on my system, kernel.domainname is a sysctl parameter for the main kernel, and trying to change it with modprobe won't work:



          # sysctl kernel.domainname
          kernel.domainname = (none)
          # modprobe kernel domainname="example.com"
          modprobe: FATAL: Module kernel not found in directory /lib/modules/<kernel_version>
          # sysctl kernel.domainname
          kernel.domainname = (none)


          In a nutshell: If you are unsure, first look into /proc/sys or the output of sysctl -a: if the parameter you're looking for is not there, it is not a sysctl parameter and is probably a module parameter (or the module that would provide the sysctl is not currently loaded, in which case it's better to set the value as a module parameter anyway - trying to set a sysctl belonging to a module that is not currently loaded will just produce an error).



          Then, find out which module the parameter belongs to. If the module is built into the kernel, you'll probably have to use a boot option; if it is loadable with modprobe (i.e. the respective <module>.ko file exists somewhere in the /lib/modules/<kernel version>/ directory tree), then you can use modprobe and/or /etc/modprobe.d/.






          share|improve this answer






















          • So basically, certain params are editable via modprobe, others via sysctl?? How can i find out which is which??
            – Somenath Sinha
            Dec 14 '17 at 9:15










          • I've edited my answer to hopefully clarify that.
            – telcoM
            Dec 14 '17 at 9:29










          • sysctl -a will also show you all the parameters that can be set with sysctl.
            – Raman Sailopal
            Dec 14 '17 at 9:33










          • That's a good point.
            – telcoM
            Dec 14 '17 at 9:52












          up vote
          4
          down vote



          accepted







          up vote
          4
          down vote



          accepted






          As far as I know, you can use modprobe to adjust parameters only when the feature in question has been compiled as a module - and you're loading the module in the first place. For setting module parameters persistently, you'll have the /etc/modprobe.d directory. (Generally you should leave /usr/lib/modprobe.d for distribution's default settings - any files in there may get overwritten by package updates.)



          If the module in question has been built into the main kernel, then you must use the <module_name>.<parameter_name>=<value> syntax, typically as a boot option. If the parameter in question is available as a sysctl setting, then you can use the sysctl -w command to adjust it too.



          All the available sysctl parameters are presented under /proc/sys: for example, kernel.domainname is at /proc/sys/kernel/domainname. Not all module parameters are available as sysctls, but some might be.



          If a loadable module has already been loaded, and you wish to change its parameters immediately without unloading it, then you can write the new value to /sys/module/<module_name>/parameters/<parameter_name>. If the module cannot accept dynamic reconfiguration for that parameter, the file will be read-only.



          At least on my system, kernel.domainname is a sysctl parameter for the main kernel, and trying to change it with modprobe won't work:



          # sysctl kernel.domainname
          kernel.domainname = (none)
          # modprobe kernel domainname="example.com"
          modprobe: FATAL: Module kernel not found in directory /lib/modules/<kernel_version>
          # sysctl kernel.domainname
          kernel.domainname = (none)


          In a nutshell: If you are unsure, first look into /proc/sys or the output of sysctl -a: if the parameter you're looking for is not there, it is not a sysctl parameter and is probably a module parameter (or the module that would provide the sysctl is not currently loaded, in which case it's better to set the value as a module parameter anyway - trying to set a sysctl belonging to a module that is not currently loaded will just produce an error).



          Then, find out which module the parameter belongs to. If the module is built into the kernel, you'll probably have to use a boot option; if it is loadable with modprobe (i.e. the respective <module>.ko file exists somewhere in the /lib/modules/<kernel version>/ directory tree), then you can use modprobe and/or /etc/modprobe.d/.






          share|improve this answer














          As far as I know, you can use modprobe to adjust parameters only when the feature in question has been compiled as a module - and you're loading the module in the first place. For setting module parameters persistently, you'll have the /etc/modprobe.d directory. (Generally you should leave /usr/lib/modprobe.d for distribution's default settings - any files in there may get overwritten by package updates.)



          If the module in question has been built into the main kernel, then you must use the <module_name>.<parameter_name>=<value> syntax, typically as a boot option. If the parameter in question is available as a sysctl setting, then you can use the sysctl -w command to adjust it too.



          All the available sysctl parameters are presented under /proc/sys: for example, kernel.domainname is at /proc/sys/kernel/domainname. Not all module parameters are available as sysctls, but some might be.



          If a loadable module has already been loaded, and you wish to change its parameters immediately without unloading it, then you can write the new value to /sys/module/<module_name>/parameters/<parameter_name>. If the module cannot accept dynamic reconfiguration for that parameter, the file will be read-only.



          At least on my system, kernel.domainname is a sysctl parameter for the main kernel, and trying to change it with modprobe won't work:



          # sysctl kernel.domainname
          kernel.domainname = (none)
          # modprobe kernel domainname="example.com"
          modprobe: FATAL: Module kernel not found in directory /lib/modules/<kernel_version>
          # sysctl kernel.domainname
          kernel.domainname = (none)


          In a nutshell: If you are unsure, first look into /proc/sys or the output of sysctl -a: if the parameter you're looking for is not there, it is not a sysctl parameter and is probably a module parameter (or the module that would provide the sysctl is not currently loaded, in which case it's better to set the value as a module parameter anyway - trying to set a sysctl belonging to a module that is not currently loaded will just produce an error).



          Then, find out which module the parameter belongs to. If the module is built into the kernel, you'll probably have to use a boot option; if it is loadable with modprobe (i.e. the respective <module>.ko file exists somewhere in the /lib/modules/<kernel version>/ directory tree), then you can use modprobe and/or /etc/modprobe.d/.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 14 '17 at 9:53

























          answered Dec 14 '17 at 9:12









          telcoM

          10.8k11232




          10.8k11232











          • So basically, certain params are editable via modprobe, others via sysctl?? How can i find out which is which??
            – Somenath Sinha
            Dec 14 '17 at 9:15










          • I've edited my answer to hopefully clarify that.
            – telcoM
            Dec 14 '17 at 9:29










          • sysctl -a will also show you all the parameters that can be set with sysctl.
            – Raman Sailopal
            Dec 14 '17 at 9:33










          • That's a good point.
            – telcoM
            Dec 14 '17 at 9:52
















          • So basically, certain params are editable via modprobe, others via sysctl?? How can i find out which is which??
            – Somenath Sinha
            Dec 14 '17 at 9:15










          • I've edited my answer to hopefully clarify that.
            – telcoM
            Dec 14 '17 at 9:29










          • sysctl -a will also show you all the parameters that can be set with sysctl.
            – Raman Sailopal
            Dec 14 '17 at 9:33










          • That's a good point.
            – telcoM
            Dec 14 '17 at 9:52















          So basically, certain params are editable via modprobe, others via sysctl?? How can i find out which is which??
          – Somenath Sinha
          Dec 14 '17 at 9:15




          So basically, certain params are editable via modprobe, others via sysctl?? How can i find out which is which??
          – Somenath Sinha
          Dec 14 '17 at 9:15












          I've edited my answer to hopefully clarify that.
          – telcoM
          Dec 14 '17 at 9:29




          I've edited my answer to hopefully clarify that.
          – telcoM
          Dec 14 '17 at 9:29












          sysctl -a will also show you all the parameters that can be set with sysctl.
          – Raman Sailopal
          Dec 14 '17 at 9:33




          sysctl -a will also show you all the parameters that can be set with sysctl.
          – Raman Sailopal
          Dec 14 '17 at 9:33












          That's a good point.
          – telcoM
          Dec 14 '17 at 9:52




          That's a good point.
          – telcoM
          Dec 14 '17 at 9:52












           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f410811%2fdifference-between-modprobe-and-sysctl-w-in-terms-of-setting-system-parameters%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Bahrain

          Postfix configuration issue with fips on centos 7; mailgun relay