Automatically Login on Debian 9.2.1 Command Line












2















I just installed Debian 9.2.1 on an old laptop as a cheap server. The computer is not physically accessed by anyone other than myself, so I would like to automatically login upon startup so that if I have to use the laptop itself rather than SSH, I don't have to bother logging in. I have no graphical environments installed, so none of those methods would work, and I've tried multiple solutions such as https://superuser.com/questions/969923/automatic-root-login-in-debian-8-0-console-only
However all it did was result in no login prompt being given at all... So I reinstalled Debian.
What can I do to automatically log in without a graphical environment? Thanks!










share|improve this question



























    2















    I just installed Debian 9.2.1 on an old laptop as a cheap server. The computer is not physically accessed by anyone other than myself, so I would like to automatically login upon startup so that if I have to use the laptop itself rather than SSH, I don't have to bother logging in. I have no graphical environments installed, so none of those methods would work, and I've tried multiple solutions such as https://superuser.com/questions/969923/automatic-root-login-in-debian-8-0-console-only
    However all it did was result in no login prompt being given at all... So I reinstalled Debian.
    What can I do to automatically log in without a graphical environment? Thanks!










    share|improve this question

























      2












      2








      2


      3






      I just installed Debian 9.2.1 on an old laptop as a cheap server. The computer is not physically accessed by anyone other than myself, so I would like to automatically login upon startup so that if I have to use the laptop itself rather than SSH, I don't have to bother logging in. I have no graphical environments installed, so none of those methods would work, and I've tried multiple solutions such as https://superuser.com/questions/969923/automatic-root-login-in-debian-8-0-console-only
      However all it did was result in no login prompt being given at all... So I reinstalled Debian.
      What can I do to automatically log in without a graphical environment? Thanks!










      share|improve this question














      I just installed Debian 9.2.1 on an old laptop as a cheap server. The computer is not physically accessed by anyone other than myself, so I would like to automatically login upon startup so that if I have to use the laptop itself rather than SSH, I don't have to bother logging in. I have no graphical environments installed, so none of those methods would work, and I've tried multiple solutions such as https://superuser.com/questions/969923/automatic-root-login-in-debian-8-0-console-only
      However all it did was result in no login prompt being given at all... So I reinstalled Debian.
      What can I do to automatically log in without a graphical environment? Thanks!







      debian login autologin






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 1 '17 at 5:14









      JoshJosh

      1313




      1313






















          3 Answers
          3






          active

          oldest

          votes


















          8














          Edit your /etc/systemd/logind.conf , change #NAutoVTs=6 to NAutoVTs=1



          Create a /etc/systemd/system/getty@tty1.service.d/override.conf through ;



          systemctl edit getty@tty1


          Past the following lines



          [Service]
          ExecStart=
          ExecStart=-/sbin/agetty --autologin root --noclear %I 38400 linux


          enable the getty@tty1.service then reboot



          systemctl enable getty@tty1.service
          reboot


          Arch linux docs :getty






          share|improve this answer
























          • I must have done something wrong, because this broke my system: unix.stackexchange.com/q/466088/37050. Worthwhile to check out depending on the answers there.

            – Keelan
            Aug 31 '18 at 18:00



















          0














          I'd like to add a slightly more thorough answer, especially given the comment about breaking his system from @Keelan.



          First if you wish to only have one TTY that is running the program, and not be able to log in to any other tty, THEN edit your /etc/systemd/logind.conf, and change #NAutoVTs=6 to NAutoVTs=1. Doing this will keep you from logging in on the terminal!



          Next create a directory and an override.conf file:



          mkdir -p /etc/systemd/system/getty@tty1.service.d
          echo "[Service]" > /etc/systemd/system/getty@tty1.service.d/override.conf
          echo "ExecStart=" >> /etc/systemd/system/getty@tty1.service.d/override.conf
          echo "ExecStart=-/sbin/agetty --autologin root --noclear %I 38400 linux" >> /etc/systemd/system/getty@tty1.service.d/override.conf


          Don't reboot. Instead of rebooting, as described in the other answer, log in to another TTY, then run the following commands to test things out:



          systemctl daemon-reload
          systemctl restart getty@tty1.service


          If all goes well, then reboot.



          But what if I want to run a program instead of autologin?
          Then you would use the following:



          mkdir -p /etc/systemd/system/getty@tty1.service.d
          echo "[Service]" > /etc/systemd/system/getty@tty1.service.d/override.conf
          echo "ExecStart=" >> /etc/systemd/system/getty@tty1.service.d/override.conf
          echo "ExecStart=-/path/program -arg1 -arg2" >> /etc/systemd/system/getty@tty1.service.d/override.conf
          echo "StandardInput=tty" >> /etc/systemd/system/getty@tty1.service.d/override.conf
          echo "StandardOutput=tty" >> /etc/systemd/system/getty@tty1.service.d/override.conf


          Now keep in mind this will run without a bashrc. This means if you use something like screen then you won't get all your usual aliases/etc. To fix that, use the standard auto-login above, but add this to your .bashrc:



          [ `tty` == /dev/tty1 ] && /path/program -arg1 -arg2


          This means that the program will only be run on tty1, but will give you a full shell underneath.



          Hope this helps!






          share|improve this answer































            0














            I just want to add to this discussion that the accepted answer pertains to virtual terminals. In my case, I had to edit a separate service file which is used for serial terminals. The file is found at /lib/systemd/system/serial-getty@.service and the same procedure of adding --autologin <user> to the appropriate line does the trick.



            [Service]
            ExecStart=-/sbin/agetty --keep-baud 115200,38400,9600 --autologin root %I $TERM





            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%2f401759%2fautomatically-login-on-debian-9-2-1-command-line%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              8














              Edit your /etc/systemd/logind.conf , change #NAutoVTs=6 to NAutoVTs=1



              Create a /etc/systemd/system/getty@tty1.service.d/override.conf through ;



              systemctl edit getty@tty1


              Past the following lines



              [Service]
              ExecStart=
              ExecStart=-/sbin/agetty --autologin root --noclear %I 38400 linux


              enable the getty@tty1.service then reboot



              systemctl enable getty@tty1.service
              reboot


              Arch linux docs :getty






              share|improve this answer
























              • I must have done something wrong, because this broke my system: unix.stackexchange.com/q/466088/37050. Worthwhile to check out depending on the answers there.

                – Keelan
                Aug 31 '18 at 18:00
















              8














              Edit your /etc/systemd/logind.conf , change #NAutoVTs=6 to NAutoVTs=1



              Create a /etc/systemd/system/getty@tty1.service.d/override.conf through ;



              systemctl edit getty@tty1


              Past the following lines



              [Service]
              ExecStart=
              ExecStart=-/sbin/agetty --autologin root --noclear %I 38400 linux


              enable the getty@tty1.service then reboot



              systemctl enable getty@tty1.service
              reboot


              Arch linux docs :getty






              share|improve this answer
























              • I must have done something wrong, because this broke my system: unix.stackexchange.com/q/466088/37050. Worthwhile to check out depending on the answers there.

                – Keelan
                Aug 31 '18 at 18:00














              8












              8








              8







              Edit your /etc/systemd/logind.conf , change #NAutoVTs=6 to NAutoVTs=1



              Create a /etc/systemd/system/getty@tty1.service.d/override.conf through ;



              systemctl edit getty@tty1


              Past the following lines



              [Service]
              ExecStart=
              ExecStart=-/sbin/agetty --autologin root --noclear %I 38400 linux


              enable the getty@tty1.service then reboot



              systemctl enable getty@tty1.service
              reboot


              Arch linux docs :getty






              share|improve this answer













              Edit your /etc/systemd/logind.conf , change #NAutoVTs=6 to NAutoVTs=1



              Create a /etc/systemd/system/getty@tty1.service.d/override.conf through ;



              systemctl edit getty@tty1


              Past the following lines



              [Service]
              ExecStart=
              ExecStart=-/sbin/agetty --autologin root --noclear %I 38400 linux


              enable the getty@tty1.service then reboot



              systemctl enable getty@tty1.service
              reboot


              Arch linux docs :getty







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Nov 1 '17 at 9:26









              GAD3RGAD3R

              26.9k1756111




              26.9k1756111













              • I must have done something wrong, because this broke my system: unix.stackexchange.com/q/466088/37050. Worthwhile to check out depending on the answers there.

                – Keelan
                Aug 31 '18 at 18:00



















              • I must have done something wrong, because this broke my system: unix.stackexchange.com/q/466088/37050. Worthwhile to check out depending on the answers there.

                – Keelan
                Aug 31 '18 at 18:00

















              I must have done something wrong, because this broke my system: unix.stackexchange.com/q/466088/37050. Worthwhile to check out depending on the answers there.

              – Keelan
              Aug 31 '18 at 18:00





              I must have done something wrong, because this broke my system: unix.stackexchange.com/q/466088/37050. Worthwhile to check out depending on the answers there.

              – Keelan
              Aug 31 '18 at 18:00













              0














              I'd like to add a slightly more thorough answer, especially given the comment about breaking his system from @Keelan.



              First if you wish to only have one TTY that is running the program, and not be able to log in to any other tty, THEN edit your /etc/systemd/logind.conf, and change #NAutoVTs=6 to NAutoVTs=1. Doing this will keep you from logging in on the terminal!



              Next create a directory and an override.conf file:



              mkdir -p /etc/systemd/system/getty@tty1.service.d
              echo "[Service]" > /etc/systemd/system/getty@tty1.service.d/override.conf
              echo "ExecStart=" >> /etc/systemd/system/getty@tty1.service.d/override.conf
              echo "ExecStart=-/sbin/agetty --autologin root --noclear %I 38400 linux" >> /etc/systemd/system/getty@tty1.service.d/override.conf


              Don't reboot. Instead of rebooting, as described in the other answer, log in to another TTY, then run the following commands to test things out:



              systemctl daemon-reload
              systemctl restart getty@tty1.service


              If all goes well, then reboot.



              But what if I want to run a program instead of autologin?
              Then you would use the following:



              mkdir -p /etc/systemd/system/getty@tty1.service.d
              echo "[Service]" > /etc/systemd/system/getty@tty1.service.d/override.conf
              echo "ExecStart=" >> /etc/systemd/system/getty@tty1.service.d/override.conf
              echo "ExecStart=-/path/program -arg1 -arg2" >> /etc/systemd/system/getty@tty1.service.d/override.conf
              echo "StandardInput=tty" >> /etc/systemd/system/getty@tty1.service.d/override.conf
              echo "StandardOutput=tty" >> /etc/systemd/system/getty@tty1.service.d/override.conf


              Now keep in mind this will run without a bashrc. This means if you use something like screen then you won't get all your usual aliases/etc. To fix that, use the standard auto-login above, but add this to your .bashrc:



              [ `tty` == /dev/tty1 ] && /path/program -arg1 -arg2


              This means that the program will only be run on tty1, but will give you a full shell underneath.



              Hope this helps!






              share|improve this answer




























                0














                I'd like to add a slightly more thorough answer, especially given the comment about breaking his system from @Keelan.



                First if you wish to only have one TTY that is running the program, and not be able to log in to any other tty, THEN edit your /etc/systemd/logind.conf, and change #NAutoVTs=6 to NAutoVTs=1. Doing this will keep you from logging in on the terminal!



                Next create a directory and an override.conf file:



                mkdir -p /etc/systemd/system/getty@tty1.service.d
                echo "[Service]" > /etc/systemd/system/getty@tty1.service.d/override.conf
                echo "ExecStart=" >> /etc/systemd/system/getty@tty1.service.d/override.conf
                echo "ExecStart=-/sbin/agetty --autologin root --noclear %I 38400 linux" >> /etc/systemd/system/getty@tty1.service.d/override.conf


                Don't reboot. Instead of rebooting, as described in the other answer, log in to another TTY, then run the following commands to test things out:



                systemctl daemon-reload
                systemctl restart getty@tty1.service


                If all goes well, then reboot.



                But what if I want to run a program instead of autologin?
                Then you would use the following:



                mkdir -p /etc/systemd/system/getty@tty1.service.d
                echo "[Service]" > /etc/systemd/system/getty@tty1.service.d/override.conf
                echo "ExecStart=" >> /etc/systemd/system/getty@tty1.service.d/override.conf
                echo "ExecStart=-/path/program -arg1 -arg2" >> /etc/systemd/system/getty@tty1.service.d/override.conf
                echo "StandardInput=tty" >> /etc/systemd/system/getty@tty1.service.d/override.conf
                echo "StandardOutput=tty" >> /etc/systemd/system/getty@tty1.service.d/override.conf


                Now keep in mind this will run without a bashrc. This means if you use something like screen then you won't get all your usual aliases/etc. To fix that, use the standard auto-login above, but add this to your .bashrc:



                [ `tty` == /dev/tty1 ] && /path/program -arg1 -arg2


                This means that the program will only be run on tty1, but will give you a full shell underneath.



                Hope this helps!






                share|improve this answer


























                  0












                  0








                  0







                  I'd like to add a slightly more thorough answer, especially given the comment about breaking his system from @Keelan.



                  First if you wish to only have one TTY that is running the program, and not be able to log in to any other tty, THEN edit your /etc/systemd/logind.conf, and change #NAutoVTs=6 to NAutoVTs=1. Doing this will keep you from logging in on the terminal!



                  Next create a directory and an override.conf file:



                  mkdir -p /etc/systemd/system/getty@tty1.service.d
                  echo "[Service]" > /etc/systemd/system/getty@tty1.service.d/override.conf
                  echo "ExecStart=" >> /etc/systemd/system/getty@tty1.service.d/override.conf
                  echo "ExecStart=-/sbin/agetty --autologin root --noclear %I 38400 linux" >> /etc/systemd/system/getty@tty1.service.d/override.conf


                  Don't reboot. Instead of rebooting, as described in the other answer, log in to another TTY, then run the following commands to test things out:



                  systemctl daemon-reload
                  systemctl restart getty@tty1.service


                  If all goes well, then reboot.



                  But what if I want to run a program instead of autologin?
                  Then you would use the following:



                  mkdir -p /etc/systemd/system/getty@tty1.service.d
                  echo "[Service]" > /etc/systemd/system/getty@tty1.service.d/override.conf
                  echo "ExecStart=" >> /etc/systemd/system/getty@tty1.service.d/override.conf
                  echo "ExecStart=-/path/program -arg1 -arg2" >> /etc/systemd/system/getty@tty1.service.d/override.conf
                  echo "StandardInput=tty" >> /etc/systemd/system/getty@tty1.service.d/override.conf
                  echo "StandardOutput=tty" >> /etc/systemd/system/getty@tty1.service.d/override.conf


                  Now keep in mind this will run without a bashrc. This means if you use something like screen then you won't get all your usual aliases/etc. To fix that, use the standard auto-login above, but add this to your .bashrc:



                  [ `tty` == /dev/tty1 ] && /path/program -arg1 -arg2


                  This means that the program will only be run on tty1, but will give you a full shell underneath.



                  Hope this helps!






                  share|improve this answer













                  I'd like to add a slightly more thorough answer, especially given the comment about breaking his system from @Keelan.



                  First if you wish to only have one TTY that is running the program, and not be able to log in to any other tty, THEN edit your /etc/systemd/logind.conf, and change #NAutoVTs=6 to NAutoVTs=1. Doing this will keep you from logging in on the terminal!



                  Next create a directory and an override.conf file:



                  mkdir -p /etc/systemd/system/getty@tty1.service.d
                  echo "[Service]" > /etc/systemd/system/getty@tty1.service.d/override.conf
                  echo "ExecStart=" >> /etc/systemd/system/getty@tty1.service.d/override.conf
                  echo "ExecStart=-/sbin/agetty --autologin root --noclear %I 38400 linux" >> /etc/systemd/system/getty@tty1.service.d/override.conf


                  Don't reboot. Instead of rebooting, as described in the other answer, log in to another TTY, then run the following commands to test things out:



                  systemctl daemon-reload
                  systemctl restart getty@tty1.service


                  If all goes well, then reboot.



                  But what if I want to run a program instead of autologin?
                  Then you would use the following:



                  mkdir -p /etc/systemd/system/getty@tty1.service.d
                  echo "[Service]" > /etc/systemd/system/getty@tty1.service.d/override.conf
                  echo "ExecStart=" >> /etc/systemd/system/getty@tty1.service.d/override.conf
                  echo "ExecStart=-/path/program -arg1 -arg2" >> /etc/systemd/system/getty@tty1.service.d/override.conf
                  echo "StandardInput=tty" >> /etc/systemd/system/getty@tty1.service.d/override.conf
                  echo "StandardOutput=tty" >> /etc/systemd/system/getty@tty1.service.d/override.conf


                  Now keep in mind this will run without a bashrc. This means if you use something like screen then you won't get all your usual aliases/etc. To fix that, use the standard auto-login above, but add this to your .bashrc:



                  [ `tty` == /dev/tty1 ] && /path/program -arg1 -arg2


                  This means that the program will only be run on tty1, but will give you a full shell underneath.



                  Hope this helps!







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Dec 14 '18 at 15:41









                  FmstratFmstrat

                  15815




                  15815























                      0














                      I just want to add to this discussion that the accepted answer pertains to virtual terminals. In my case, I had to edit a separate service file which is used for serial terminals. The file is found at /lib/systemd/system/serial-getty@.service and the same procedure of adding --autologin <user> to the appropriate line does the trick.



                      [Service]
                      ExecStart=-/sbin/agetty --keep-baud 115200,38400,9600 --autologin root %I $TERM





                      share|improve this answer




























                        0














                        I just want to add to this discussion that the accepted answer pertains to virtual terminals. In my case, I had to edit a separate service file which is used for serial terminals. The file is found at /lib/systemd/system/serial-getty@.service and the same procedure of adding --autologin <user> to the appropriate line does the trick.



                        [Service]
                        ExecStart=-/sbin/agetty --keep-baud 115200,38400,9600 --autologin root %I $TERM





                        share|improve this answer


























                          0












                          0








                          0







                          I just want to add to this discussion that the accepted answer pertains to virtual terminals. In my case, I had to edit a separate service file which is used for serial terminals. The file is found at /lib/systemd/system/serial-getty@.service and the same procedure of adding --autologin <user> to the appropriate line does the trick.



                          [Service]
                          ExecStart=-/sbin/agetty --keep-baud 115200,38400,9600 --autologin root %I $TERM





                          share|improve this answer













                          I just want to add to this discussion that the accepted answer pertains to virtual terminals. In my case, I had to edit a separate service file which is used for serial terminals. The file is found at /lib/systemd/system/serial-getty@.service and the same procedure of adding --autologin <user> to the appropriate line does the trick.



                          [Service]
                          ExecStart=-/sbin/agetty --keep-baud 115200,38400,9600 --autologin root %I $TERM






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Feb 15 at 18:54









                          drummerboydrummerboy

                          1




                          1






























                              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%2f401759%2fautomatically-login-on-debian-9-2-1-command-line%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 reconfigure Docker Trusted Registry 2.x.x to use CEPH FS mount instead of NFS and other traditional...

                              is 'sed' thread safe

                              How to make a Squid Proxy server?