How can I automatically set the core dump size on a single user?

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











up vote
0
down vote

favorite
1












I am running OpenSUSE. I usually open the console with an interactive non-login shell bash, and frequently use tcsh after logon. I am writing some C code, compiling with gcc, and I'd like to have the core dump files created whenever an executable fails.



I know I can select manually the core dump size to be unlimited, but I don't want to type



limits coredumpsize unlimited


in tcsh or



ulimit -c unlimited


in the default shell bash every time I log on as my user.



Is there a way to set the core dump size automatically whenever I logon as user in bash and/or tcsh?







share|improve this question


























    up vote
    0
    down vote

    favorite
    1












    I am running OpenSUSE. I usually open the console with an interactive non-login shell bash, and frequently use tcsh after logon. I am writing some C code, compiling with gcc, and I'd like to have the core dump files created whenever an executable fails.



    I know I can select manually the core dump size to be unlimited, but I don't want to type



    limits coredumpsize unlimited


    in tcsh or



    ulimit -c unlimited


    in the default shell bash every time I log on as my user.



    Is there a way to set the core dump size automatically whenever I logon as user in bash and/or tcsh?







    share|improve this question
























      up vote
      0
      down vote

      favorite
      1









      up vote
      0
      down vote

      favorite
      1






      1





      I am running OpenSUSE. I usually open the console with an interactive non-login shell bash, and frequently use tcsh after logon. I am writing some C code, compiling with gcc, and I'd like to have the core dump files created whenever an executable fails.



      I know I can select manually the core dump size to be unlimited, but I don't want to type



      limits coredumpsize unlimited


      in tcsh or



      ulimit -c unlimited


      in the default shell bash every time I log on as my user.



      Is there a way to set the core dump size automatically whenever I logon as user in bash and/or tcsh?







      share|improve this question














      I am running OpenSUSE. I usually open the console with an interactive non-login shell bash, and frequently use tcsh after logon. I am writing some C code, compiling with gcc, and I'd like to have the core dump files created whenever an executable fails.



      I know I can select manually the core dump size to be unlimited, but I don't want to type



      limits coredumpsize unlimited


      in tcsh or



      ulimit -c unlimited


      in the default shell bash every time I log on as my user.



      Is there a way to set the core dump size automatically whenever I logon as user in bash and/or tcsh?









      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 26 at 8:01

























      asked Mar 23 at 1:56









      Andrea L.

      1014




      1014




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote



          accepted










          After a bit of research I may have solved the problem. Once I login to the UNIX machine, it redirects me to the home directory, according to the shell chosen, from the available ones on the system from the file etcpasswd as follows:



          alandella:x:1000:100:alandella:/home/alandella:/bin/bash


          This explains the non-login interactive bash shell (konsole). The shell, let it be bash or tcsh runs, and the following files are read at login/logout:



          ~/.login -> Executes cmds at login
          ~/.tcshrc -> same as ~./bashrc in bash and ~./cshrc in csh
          ~/.logout -> at logout


          So, by adding the following lines to the ~/.tcshrc and ~/.bashrc files:



          ~/.bashrc -> ulimit -Sc X
          ~/.tcshrc -> limit coredumpsize X


          where X is a value (kB) or unlimited, and it should do the trick.



          Sometimes, it is told to also edit the ~/.profile file. I did not edit it, even if MY bash shell sources it at login. Why does it not make a difference? Because I always use a non-login shell, as I double-click konsole to open the terminal. The ~/.profile file is sourced at startup only in a login shell (usually sh, which I do not use). I have bash that looks at the following files in sequence:



          .bash_profile -> .bash_login -> .profile


          in MY case, the first two files do not exist, so bash sources .profile if I use a login shell.



          NOTE. This operation must be done as root, and in order to make this trick work, the following conditions must/should be met:



          1. That the file /etc/security/limits.conf sets suitable hard/soft limits for the user and root. If a hard limit of the core dump size of 2000 kB is imposed, then when we modify ~/.bashrc with 3000 kB, the core dump size limit will continue to be 2000 kB. Lookup limits.conf.


          2. That the files under /etc/pam.d contain the session required pam_limits.so line, in order to allow the /etc/security/limits.conf settings to take place.


          3. That the file /etc/sysctl.conf contains kernel.core_pattern = core.%e.%p, this sets the format of the generated core files, where %e is the executable filename and %p is the pid.






          share|improve this answer




















          • Note: the ~/.bashrc, ~/.cshrc and ~/.tcshrc are initialisation scripts which are read at each shell or subshell. If for example you run a shell script which make a loop running another subshell 1000 times, this initialisation script will be read 1000 times. The ulimit or limit you need, has to be called only once and so has to be called within ~/.profile or ~/.login.
            – daniel Azuelos
            Mar 26 at 11:06











          • @danielAzuelos I tried that, but whenever I delete the lines in ~/.bashrc or ~/.tcshrc and add the new limit setting in ~/.profile, the soft limit for the core sticks at 0 for some wizardry I cannot wrap my head around
            – Andrea L.
            Mar 26 at 12:30










          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%2f432978%2fhow-can-i-automatically-set-the-core-dump-size-on-a-single-user%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
          0
          down vote



          accepted










          After a bit of research I may have solved the problem. Once I login to the UNIX machine, it redirects me to the home directory, according to the shell chosen, from the available ones on the system from the file etcpasswd as follows:



          alandella:x:1000:100:alandella:/home/alandella:/bin/bash


          This explains the non-login interactive bash shell (konsole). The shell, let it be bash or tcsh runs, and the following files are read at login/logout:



          ~/.login -> Executes cmds at login
          ~/.tcshrc -> same as ~./bashrc in bash and ~./cshrc in csh
          ~/.logout -> at logout


          So, by adding the following lines to the ~/.tcshrc and ~/.bashrc files:



          ~/.bashrc -> ulimit -Sc X
          ~/.tcshrc -> limit coredumpsize X


          where X is a value (kB) or unlimited, and it should do the trick.



          Sometimes, it is told to also edit the ~/.profile file. I did not edit it, even if MY bash shell sources it at login. Why does it not make a difference? Because I always use a non-login shell, as I double-click konsole to open the terminal. The ~/.profile file is sourced at startup only in a login shell (usually sh, which I do not use). I have bash that looks at the following files in sequence:



          .bash_profile -> .bash_login -> .profile


          in MY case, the first two files do not exist, so bash sources .profile if I use a login shell.



          NOTE. This operation must be done as root, and in order to make this trick work, the following conditions must/should be met:



          1. That the file /etc/security/limits.conf sets suitable hard/soft limits for the user and root. If a hard limit of the core dump size of 2000 kB is imposed, then when we modify ~/.bashrc with 3000 kB, the core dump size limit will continue to be 2000 kB. Lookup limits.conf.


          2. That the files under /etc/pam.d contain the session required pam_limits.so line, in order to allow the /etc/security/limits.conf settings to take place.


          3. That the file /etc/sysctl.conf contains kernel.core_pattern = core.%e.%p, this sets the format of the generated core files, where %e is the executable filename and %p is the pid.






          share|improve this answer




















          • Note: the ~/.bashrc, ~/.cshrc and ~/.tcshrc are initialisation scripts which are read at each shell or subshell. If for example you run a shell script which make a loop running another subshell 1000 times, this initialisation script will be read 1000 times. The ulimit or limit you need, has to be called only once and so has to be called within ~/.profile or ~/.login.
            – daniel Azuelos
            Mar 26 at 11:06











          • @danielAzuelos I tried that, but whenever I delete the lines in ~/.bashrc or ~/.tcshrc and add the new limit setting in ~/.profile, the soft limit for the core sticks at 0 for some wizardry I cannot wrap my head around
            – Andrea L.
            Mar 26 at 12:30














          up vote
          0
          down vote



          accepted










          After a bit of research I may have solved the problem. Once I login to the UNIX machine, it redirects me to the home directory, according to the shell chosen, from the available ones on the system from the file etcpasswd as follows:



          alandella:x:1000:100:alandella:/home/alandella:/bin/bash


          This explains the non-login interactive bash shell (konsole). The shell, let it be bash or tcsh runs, and the following files are read at login/logout:



          ~/.login -> Executes cmds at login
          ~/.tcshrc -> same as ~./bashrc in bash and ~./cshrc in csh
          ~/.logout -> at logout


          So, by adding the following lines to the ~/.tcshrc and ~/.bashrc files:



          ~/.bashrc -> ulimit -Sc X
          ~/.tcshrc -> limit coredumpsize X


          where X is a value (kB) or unlimited, and it should do the trick.



          Sometimes, it is told to also edit the ~/.profile file. I did not edit it, even if MY bash shell sources it at login. Why does it not make a difference? Because I always use a non-login shell, as I double-click konsole to open the terminal. The ~/.profile file is sourced at startup only in a login shell (usually sh, which I do not use). I have bash that looks at the following files in sequence:



          .bash_profile -> .bash_login -> .profile


          in MY case, the first two files do not exist, so bash sources .profile if I use a login shell.



          NOTE. This operation must be done as root, and in order to make this trick work, the following conditions must/should be met:



          1. That the file /etc/security/limits.conf sets suitable hard/soft limits for the user and root. If a hard limit of the core dump size of 2000 kB is imposed, then when we modify ~/.bashrc with 3000 kB, the core dump size limit will continue to be 2000 kB. Lookup limits.conf.


          2. That the files under /etc/pam.d contain the session required pam_limits.so line, in order to allow the /etc/security/limits.conf settings to take place.


          3. That the file /etc/sysctl.conf contains kernel.core_pattern = core.%e.%p, this sets the format of the generated core files, where %e is the executable filename and %p is the pid.






          share|improve this answer




















          • Note: the ~/.bashrc, ~/.cshrc and ~/.tcshrc are initialisation scripts which are read at each shell or subshell. If for example you run a shell script which make a loop running another subshell 1000 times, this initialisation script will be read 1000 times. The ulimit or limit you need, has to be called only once and so has to be called within ~/.profile or ~/.login.
            – daniel Azuelos
            Mar 26 at 11:06











          • @danielAzuelos I tried that, but whenever I delete the lines in ~/.bashrc or ~/.tcshrc and add the new limit setting in ~/.profile, the soft limit for the core sticks at 0 for some wizardry I cannot wrap my head around
            – Andrea L.
            Mar 26 at 12:30












          up vote
          0
          down vote



          accepted







          up vote
          0
          down vote



          accepted






          After a bit of research I may have solved the problem. Once I login to the UNIX machine, it redirects me to the home directory, according to the shell chosen, from the available ones on the system from the file etcpasswd as follows:



          alandella:x:1000:100:alandella:/home/alandella:/bin/bash


          This explains the non-login interactive bash shell (konsole). The shell, let it be bash or tcsh runs, and the following files are read at login/logout:



          ~/.login -> Executes cmds at login
          ~/.tcshrc -> same as ~./bashrc in bash and ~./cshrc in csh
          ~/.logout -> at logout


          So, by adding the following lines to the ~/.tcshrc and ~/.bashrc files:



          ~/.bashrc -> ulimit -Sc X
          ~/.tcshrc -> limit coredumpsize X


          where X is a value (kB) or unlimited, and it should do the trick.



          Sometimes, it is told to also edit the ~/.profile file. I did not edit it, even if MY bash shell sources it at login. Why does it not make a difference? Because I always use a non-login shell, as I double-click konsole to open the terminal. The ~/.profile file is sourced at startup only in a login shell (usually sh, which I do not use). I have bash that looks at the following files in sequence:



          .bash_profile -> .bash_login -> .profile


          in MY case, the first two files do not exist, so bash sources .profile if I use a login shell.



          NOTE. This operation must be done as root, and in order to make this trick work, the following conditions must/should be met:



          1. That the file /etc/security/limits.conf sets suitable hard/soft limits for the user and root. If a hard limit of the core dump size of 2000 kB is imposed, then when we modify ~/.bashrc with 3000 kB, the core dump size limit will continue to be 2000 kB. Lookup limits.conf.


          2. That the files under /etc/pam.d contain the session required pam_limits.so line, in order to allow the /etc/security/limits.conf settings to take place.


          3. That the file /etc/sysctl.conf contains kernel.core_pattern = core.%e.%p, this sets the format of the generated core files, where %e is the executable filename and %p is the pid.






          share|improve this answer












          After a bit of research I may have solved the problem. Once I login to the UNIX machine, it redirects me to the home directory, according to the shell chosen, from the available ones on the system from the file etcpasswd as follows:



          alandella:x:1000:100:alandella:/home/alandella:/bin/bash


          This explains the non-login interactive bash shell (konsole). The shell, let it be bash or tcsh runs, and the following files are read at login/logout:



          ~/.login -> Executes cmds at login
          ~/.tcshrc -> same as ~./bashrc in bash and ~./cshrc in csh
          ~/.logout -> at logout


          So, by adding the following lines to the ~/.tcshrc and ~/.bashrc files:



          ~/.bashrc -> ulimit -Sc X
          ~/.tcshrc -> limit coredumpsize X


          where X is a value (kB) or unlimited, and it should do the trick.



          Sometimes, it is told to also edit the ~/.profile file. I did not edit it, even if MY bash shell sources it at login. Why does it not make a difference? Because I always use a non-login shell, as I double-click konsole to open the terminal. The ~/.profile file is sourced at startup only in a login shell (usually sh, which I do not use). I have bash that looks at the following files in sequence:



          .bash_profile -> .bash_login -> .profile


          in MY case, the first two files do not exist, so bash sources .profile if I use a login shell.



          NOTE. This operation must be done as root, and in order to make this trick work, the following conditions must/should be met:



          1. That the file /etc/security/limits.conf sets suitable hard/soft limits for the user and root. If a hard limit of the core dump size of 2000 kB is imposed, then when we modify ~/.bashrc with 3000 kB, the core dump size limit will continue to be 2000 kB. Lookup limits.conf.


          2. That the files under /etc/pam.d contain the session required pam_limits.so line, in order to allow the /etc/security/limits.conf settings to take place.


          3. That the file /etc/sysctl.conf contains kernel.core_pattern = core.%e.%p, this sets the format of the generated core files, where %e is the executable filename and %p is the pid.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 26 at 10:09









          Andrea L.

          1014




          1014











          • Note: the ~/.bashrc, ~/.cshrc and ~/.tcshrc are initialisation scripts which are read at each shell or subshell. If for example you run a shell script which make a loop running another subshell 1000 times, this initialisation script will be read 1000 times. The ulimit or limit you need, has to be called only once and so has to be called within ~/.profile or ~/.login.
            – daniel Azuelos
            Mar 26 at 11:06











          • @danielAzuelos I tried that, but whenever I delete the lines in ~/.bashrc or ~/.tcshrc and add the new limit setting in ~/.profile, the soft limit for the core sticks at 0 for some wizardry I cannot wrap my head around
            – Andrea L.
            Mar 26 at 12:30
















          • Note: the ~/.bashrc, ~/.cshrc and ~/.tcshrc are initialisation scripts which are read at each shell or subshell. If for example you run a shell script which make a loop running another subshell 1000 times, this initialisation script will be read 1000 times. The ulimit or limit you need, has to be called only once and so has to be called within ~/.profile or ~/.login.
            – daniel Azuelos
            Mar 26 at 11:06











          • @danielAzuelos I tried that, but whenever I delete the lines in ~/.bashrc or ~/.tcshrc and add the new limit setting in ~/.profile, the soft limit for the core sticks at 0 for some wizardry I cannot wrap my head around
            – Andrea L.
            Mar 26 at 12:30















          Note: the ~/.bashrc, ~/.cshrc and ~/.tcshrc are initialisation scripts which are read at each shell or subshell. If for example you run a shell script which make a loop running another subshell 1000 times, this initialisation script will be read 1000 times. The ulimit or limit you need, has to be called only once and so has to be called within ~/.profile or ~/.login.
          – daniel Azuelos
          Mar 26 at 11:06





          Note: the ~/.bashrc, ~/.cshrc and ~/.tcshrc are initialisation scripts which are read at each shell or subshell. If for example you run a shell script which make a loop running another subshell 1000 times, this initialisation script will be read 1000 times. The ulimit or limit you need, has to be called only once and so has to be called within ~/.profile or ~/.login.
          – daniel Azuelos
          Mar 26 at 11:06













          @danielAzuelos I tried that, but whenever I delete the lines in ~/.bashrc or ~/.tcshrc and add the new limit setting in ~/.profile, the soft limit for the core sticks at 0 for some wizardry I cannot wrap my head around
          – Andrea L.
          Mar 26 at 12:30




          @danielAzuelos I tried that, but whenever I delete the lines in ~/.bashrc or ~/.tcshrc and add the new limit setting in ~/.profile, the soft limit for the core sticks at 0 for some wizardry I cannot wrap my head around
          – Andrea L.
          Mar 26 at 12:30












           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f432978%2fhow-can-i-automatically-set-the-core-dump-size-on-a-single-user%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