Difference between .xinitrc, .xsession and .xsessionrc

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











up vote
39
down vote

favorite
20












I found three configuration files.



  1. .xinitrc

  2. .xsession

  3. .xsessionrc

I know that the first one is for using startx and the second and third are used when using a display manager. But what is the difference between the last two?










share|improve this question



























    up vote
    39
    down vote

    favorite
    20












    I found three configuration files.



    1. .xinitrc

    2. .xsession

    3. .xsessionrc

    I know that the first one is for using startx and the second and third are used when using a display manager. But what is the difference between the last two?










    share|improve this question

























      up vote
      39
      down vote

      favorite
      20









      up vote
      39
      down vote

      favorite
      20






      20





      I found three configuration files.



      1. .xinitrc

      2. .xsession

      3. .xsessionrc

      I know that the first one is for using startx and the second and third are used when using a display manager. But what is the difference between the last two?










      share|improve this question















      I found three configuration files.



      1. .xinitrc

      2. .xsession

      3. .xsessionrc

      I know that the first one is for using startx and the second and third are used when using a display manager. But what is the difference between the last two?







      x11 login startx xinit






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited May 9 '16 at 0:04









      Gilles

      517k12410321560




      517k12410321560










      asked May 8 '16 at 16:27









      lockdoc

      311138




      311138




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          41
          down vote



          accepted










          ~/.xinitrc is executed by xinit, which is usually invoked via startx. This program is executed after logging in: first you log in on a text console, then you start the GUI with startx. The role of .xinitrc is to start the GUI part of the session, typically by setting some GUI-related settings such as key bindings (with xmodmap or xkbcomp), X resources (with xrdb), etc., and to launch a session manager or a window manager (possibly as part of a desktop environment).



          ~/.xsession is executed when you log in in graphical mode (on a display manager) and the display manager invokes the “custom” session type. (With the historical display manager xdm, .xsession is always executed, but with modern display managers that give the user a choice of session type, you usually need to pick “custom” for .xsession to run.) Its role is both to set login-time parameters (such as environment variables) and to start the GUI session. A typical .xsession is



          #!/bin/sh
          . ~/.profile
          . ~/.xinitrc


          ~/.xsessionrc is executed on Debian (and derivatives such as Ubuntu, Linux Mint, etc.) by the X startup scripts on a GUI login, for all session types and (I think) from all display managers. It's also executed from startx if the user doesn't have a .xinitrc, because in that case startx falls back on the same session startup scripts that are used for GUI login. It's executed relatively early, after loading resources but before starting any program such as a key agent, a D-Bus daemon, etc. It typically sets variables that can be used by later startup scripts. It doesn't have any official documentation that I know of, you have to dig into the source to see what works.



          .xinitrc and .xsession are historical features of the X11 Window system so they should be available and have a similar behavior on all Unix systems. On the other hand, .xsessionrc is a Debian feature and distributions that are not based on Debian don't have it unless they've implemented something similar.



          .xprofile is very similar to .xsessionrc, but it's part of the session startup script of GDM (the GNOME display manager), so it's only read if you log in with GDM.






          share|improve this answer



























            up vote
            3
            down vote













            According to another discussion, startx + ~/.xsession and no ~/.xinitrc, results in reduced functionality (xfce4, sid)




            Firstly: .xsessionrc is for holding global environment variables.
            The emphasis is mine.



            Secondly: 40x11-common_xsessionrc in /etc/X11/Xsession.d is sourced
            before 50x11-common_determine-startup. So .xsessionrc is read before
            .xsession and any environment variables set will become available to
            applications run by the commands in .xsession.




            Further reading:



            • Xsession - initialize X session

            • Understanding *NIX Login Scripts





            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',
              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%2f281858%2fdifference-between-xinitrc-xsession-and-xsessionrc%23new-answer', 'question_page');

              );

              Post as a guest






























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              41
              down vote



              accepted










              ~/.xinitrc is executed by xinit, which is usually invoked via startx. This program is executed after logging in: first you log in on a text console, then you start the GUI with startx. The role of .xinitrc is to start the GUI part of the session, typically by setting some GUI-related settings such as key bindings (with xmodmap or xkbcomp), X resources (with xrdb), etc., and to launch a session manager or a window manager (possibly as part of a desktop environment).



              ~/.xsession is executed when you log in in graphical mode (on a display manager) and the display manager invokes the “custom” session type. (With the historical display manager xdm, .xsession is always executed, but with modern display managers that give the user a choice of session type, you usually need to pick “custom” for .xsession to run.) Its role is both to set login-time parameters (such as environment variables) and to start the GUI session. A typical .xsession is



              #!/bin/sh
              . ~/.profile
              . ~/.xinitrc


              ~/.xsessionrc is executed on Debian (and derivatives such as Ubuntu, Linux Mint, etc.) by the X startup scripts on a GUI login, for all session types and (I think) from all display managers. It's also executed from startx if the user doesn't have a .xinitrc, because in that case startx falls back on the same session startup scripts that are used for GUI login. It's executed relatively early, after loading resources but before starting any program such as a key agent, a D-Bus daemon, etc. It typically sets variables that can be used by later startup scripts. It doesn't have any official documentation that I know of, you have to dig into the source to see what works.



              .xinitrc and .xsession are historical features of the X11 Window system so they should be available and have a similar behavior on all Unix systems. On the other hand, .xsessionrc is a Debian feature and distributions that are not based on Debian don't have it unless they've implemented something similar.



              .xprofile is very similar to .xsessionrc, but it's part of the session startup script of GDM (the GNOME display manager), so it's only read if you log in with GDM.






              share|improve this answer
























                up vote
                41
                down vote



                accepted










                ~/.xinitrc is executed by xinit, which is usually invoked via startx. This program is executed after logging in: first you log in on a text console, then you start the GUI with startx. The role of .xinitrc is to start the GUI part of the session, typically by setting some GUI-related settings such as key bindings (with xmodmap or xkbcomp), X resources (with xrdb), etc., and to launch a session manager or a window manager (possibly as part of a desktop environment).



                ~/.xsession is executed when you log in in graphical mode (on a display manager) and the display manager invokes the “custom” session type. (With the historical display manager xdm, .xsession is always executed, but with modern display managers that give the user a choice of session type, you usually need to pick “custom” for .xsession to run.) Its role is both to set login-time parameters (such as environment variables) and to start the GUI session. A typical .xsession is



                #!/bin/sh
                . ~/.profile
                . ~/.xinitrc


                ~/.xsessionrc is executed on Debian (and derivatives such as Ubuntu, Linux Mint, etc.) by the X startup scripts on a GUI login, for all session types and (I think) from all display managers. It's also executed from startx if the user doesn't have a .xinitrc, because in that case startx falls back on the same session startup scripts that are used for GUI login. It's executed relatively early, after loading resources but before starting any program such as a key agent, a D-Bus daemon, etc. It typically sets variables that can be used by later startup scripts. It doesn't have any official documentation that I know of, you have to dig into the source to see what works.



                .xinitrc and .xsession are historical features of the X11 Window system so they should be available and have a similar behavior on all Unix systems. On the other hand, .xsessionrc is a Debian feature and distributions that are not based on Debian don't have it unless they've implemented something similar.



                .xprofile is very similar to .xsessionrc, but it's part of the session startup script of GDM (the GNOME display manager), so it's only read if you log in with GDM.






                share|improve this answer






















                  up vote
                  41
                  down vote



                  accepted







                  up vote
                  41
                  down vote



                  accepted






                  ~/.xinitrc is executed by xinit, which is usually invoked via startx. This program is executed after logging in: first you log in on a text console, then you start the GUI with startx. The role of .xinitrc is to start the GUI part of the session, typically by setting some GUI-related settings such as key bindings (with xmodmap or xkbcomp), X resources (with xrdb), etc., and to launch a session manager or a window manager (possibly as part of a desktop environment).



                  ~/.xsession is executed when you log in in graphical mode (on a display manager) and the display manager invokes the “custom” session type. (With the historical display manager xdm, .xsession is always executed, but with modern display managers that give the user a choice of session type, you usually need to pick “custom” for .xsession to run.) Its role is both to set login-time parameters (such as environment variables) and to start the GUI session. A typical .xsession is



                  #!/bin/sh
                  . ~/.profile
                  . ~/.xinitrc


                  ~/.xsessionrc is executed on Debian (and derivatives such as Ubuntu, Linux Mint, etc.) by the X startup scripts on a GUI login, for all session types and (I think) from all display managers. It's also executed from startx if the user doesn't have a .xinitrc, because in that case startx falls back on the same session startup scripts that are used for GUI login. It's executed relatively early, after loading resources but before starting any program such as a key agent, a D-Bus daemon, etc. It typically sets variables that can be used by later startup scripts. It doesn't have any official documentation that I know of, you have to dig into the source to see what works.



                  .xinitrc and .xsession are historical features of the X11 Window system so they should be available and have a similar behavior on all Unix systems. On the other hand, .xsessionrc is a Debian feature and distributions that are not based on Debian don't have it unless they've implemented something similar.



                  .xprofile is very similar to .xsessionrc, but it's part of the session startup script of GDM (the GNOME display manager), so it's only read if you log in with GDM.






                  share|improve this answer












                  ~/.xinitrc is executed by xinit, which is usually invoked via startx. This program is executed after logging in: first you log in on a text console, then you start the GUI with startx. The role of .xinitrc is to start the GUI part of the session, typically by setting some GUI-related settings such as key bindings (with xmodmap or xkbcomp), X resources (with xrdb), etc., and to launch a session manager or a window manager (possibly as part of a desktop environment).



                  ~/.xsession is executed when you log in in graphical mode (on a display manager) and the display manager invokes the “custom” session type. (With the historical display manager xdm, .xsession is always executed, but with modern display managers that give the user a choice of session type, you usually need to pick “custom” for .xsession to run.) Its role is both to set login-time parameters (such as environment variables) and to start the GUI session. A typical .xsession is



                  #!/bin/sh
                  . ~/.profile
                  . ~/.xinitrc


                  ~/.xsessionrc is executed on Debian (and derivatives such as Ubuntu, Linux Mint, etc.) by the X startup scripts on a GUI login, for all session types and (I think) from all display managers. It's also executed from startx if the user doesn't have a .xinitrc, because in that case startx falls back on the same session startup scripts that are used for GUI login. It's executed relatively early, after loading resources but before starting any program such as a key agent, a D-Bus daemon, etc. It typically sets variables that can be used by later startup scripts. It doesn't have any official documentation that I know of, you have to dig into the source to see what works.



                  .xinitrc and .xsession are historical features of the X11 Window system so they should be available and have a similar behavior on all Unix systems. On the other hand, .xsessionrc is a Debian feature and distributions that are not based on Debian don't have it unless they've implemented something similar.



                  .xprofile is very similar to .xsessionrc, but it's part of the session startup script of GDM (the GNOME display manager), so it's only read if you log in with GDM.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered May 9 '16 at 0:04









                  Gilles

                  517k12410321560




                  517k12410321560






















                      up vote
                      3
                      down vote













                      According to another discussion, startx + ~/.xsession and no ~/.xinitrc, results in reduced functionality (xfce4, sid)




                      Firstly: .xsessionrc is for holding global environment variables.
                      The emphasis is mine.



                      Secondly: 40x11-common_xsessionrc in /etc/X11/Xsession.d is sourced
                      before 50x11-common_determine-startup. So .xsessionrc is read before
                      .xsession and any environment variables set will become available to
                      applications run by the commands in .xsession.




                      Further reading:



                      • Xsession - initialize X session

                      • Understanding *NIX Login Scripts





                      share|improve this answer


























                        up vote
                        3
                        down vote













                        According to another discussion, startx + ~/.xsession and no ~/.xinitrc, results in reduced functionality (xfce4, sid)




                        Firstly: .xsessionrc is for holding global environment variables.
                        The emphasis is mine.



                        Secondly: 40x11-common_xsessionrc in /etc/X11/Xsession.d is sourced
                        before 50x11-common_determine-startup. So .xsessionrc is read before
                        .xsession and any environment variables set will become available to
                        applications run by the commands in .xsession.




                        Further reading:



                        • Xsession - initialize X session

                        • Understanding *NIX Login Scripts





                        share|improve this answer
























                          up vote
                          3
                          down vote










                          up vote
                          3
                          down vote









                          According to another discussion, startx + ~/.xsession and no ~/.xinitrc, results in reduced functionality (xfce4, sid)




                          Firstly: .xsessionrc is for holding global environment variables.
                          The emphasis is mine.



                          Secondly: 40x11-common_xsessionrc in /etc/X11/Xsession.d is sourced
                          before 50x11-common_determine-startup. So .xsessionrc is read before
                          .xsession and any environment variables set will become available to
                          applications run by the commands in .xsession.




                          Further reading:



                          • Xsession - initialize X session

                          • Understanding *NIX Login Scripts





                          share|improve this answer














                          According to another discussion, startx + ~/.xsession and no ~/.xinitrc, results in reduced functionality (xfce4, sid)




                          Firstly: .xsessionrc is for holding global environment variables.
                          The emphasis is mine.



                          Secondly: 40x11-common_xsessionrc in /etc/X11/Xsession.d is sourced
                          before 50x11-common_determine-startup. So .xsessionrc is read before
                          .xsession and any environment variables set will become available to
                          applications run by the commands in .xsession.




                          Further reading:



                          • Xsession - initialize X session

                          • Understanding *NIX Login Scripts






                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited 10 mins ago

























                          answered May 8 '16 at 17:46









                          Thomas Dickey

                          51.1k593163




                          51.1k593163



























                               

                              draft saved


                              draft discarded















































                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f281858%2fdifference-between-xinitrc-xsession-and-xsessionrc%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?

                              Displaying single band from multi-band raster using QGIS

                              How many registers does an x86_64 CPU actually have?