How do I switch users on Amazon Linux for EC2 instances?

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












0















I saw



  • How to change to normal user in the command line when logged in as the root user?

  • How to switch between users on one terminal?

I have access to sudo. I tried



[ec2-user@ip-172-99-99-99 Weekly Report]$ sudo su - jenkins
Last login: Tue Jan 29 20:26:37 UTC 2019 on pts/0
Last failed login: Tue Jan 29 20:32:30 UTC 2019 on pts/0
[ec2-user@ip-172-99-99-99 Weekly Report]$ id; whoami
uid=500(ec2-user) gid=500(ec2-user) groups=500(ec2-user),10(wheel)
ec2-user
[ec2-user@ip-172-99-99-99 Weekly Report]$ touch tmp.txt
touch: cannot touch ‘tmp.txt’: Permission denied
[ec2-user@ip-172-99-99-99 Weekly Report]$ ls -ld .
drwxr-xr-x 7 jenkins jenkins 4096 Jan 28 09:00 .


I need to execute commands as the Jenkins user to troubleshoot Maven issues.










share|improve this question
























  • Does the jenkins user share a uid (500) with ec2-user?

    – Jeff Schaller
    Jan 29 at 20:42











  • No they don't. From /etc/passwd: ec2-user:x:500:500:EC2 Default User:/home/ec2-user:/bin/bashn jenkins:x:498:497:Jenkins Automation Server:/var/lib/jenkins:/bin/false

    – Chloe
    Jan 30 at 23:38
















0















I saw



  • How to change to normal user in the command line when logged in as the root user?

  • How to switch between users on one terminal?

I have access to sudo. I tried



[ec2-user@ip-172-99-99-99 Weekly Report]$ sudo su - jenkins
Last login: Tue Jan 29 20:26:37 UTC 2019 on pts/0
Last failed login: Tue Jan 29 20:32:30 UTC 2019 on pts/0
[ec2-user@ip-172-99-99-99 Weekly Report]$ id; whoami
uid=500(ec2-user) gid=500(ec2-user) groups=500(ec2-user),10(wheel)
ec2-user
[ec2-user@ip-172-99-99-99 Weekly Report]$ touch tmp.txt
touch: cannot touch ‘tmp.txt’: Permission denied
[ec2-user@ip-172-99-99-99 Weekly Report]$ ls -ld .
drwxr-xr-x 7 jenkins jenkins 4096 Jan 28 09:00 .


I need to execute commands as the Jenkins user to troubleshoot Maven issues.










share|improve this question
























  • Does the jenkins user share a uid (500) with ec2-user?

    – Jeff Schaller
    Jan 29 at 20:42











  • No they don't. From /etc/passwd: ec2-user:x:500:500:EC2 Default User:/home/ec2-user:/bin/bashn jenkins:x:498:497:Jenkins Automation Server:/var/lib/jenkins:/bin/false

    – Chloe
    Jan 30 at 23:38














0












0








0








I saw



  • How to change to normal user in the command line when logged in as the root user?

  • How to switch between users on one terminal?

I have access to sudo. I tried



[ec2-user@ip-172-99-99-99 Weekly Report]$ sudo su - jenkins
Last login: Tue Jan 29 20:26:37 UTC 2019 on pts/0
Last failed login: Tue Jan 29 20:32:30 UTC 2019 on pts/0
[ec2-user@ip-172-99-99-99 Weekly Report]$ id; whoami
uid=500(ec2-user) gid=500(ec2-user) groups=500(ec2-user),10(wheel)
ec2-user
[ec2-user@ip-172-99-99-99 Weekly Report]$ touch tmp.txt
touch: cannot touch ‘tmp.txt’: Permission denied
[ec2-user@ip-172-99-99-99 Weekly Report]$ ls -ld .
drwxr-xr-x 7 jenkins jenkins 4096 Jan 28 09:00 .


I need to execute commands as the Jenkins user to troubleshoot Maven issues.










share|improve this question
















I saw



  • How to change to normal user in the command line when logged in as the root user?

  • How to switch between users on one terminal?

I have access to sudo. I tried



[ec2-user@ip-172-99-99-99 Weekly Report]$ sudo su - jenkins
Last login: Tue Jan 29 20:26:37 UTC 2019 on pts/0
Last failed login: Tue Jan 29 20:32:30 UTC 2019 on pts/0
[ec2-user@ip-172-99-99-99 Weekly Report]$ id; whoami
uid=500(ec2-user) gid=500(ec2-user) groups=500(ec2-user),10(wheel)
ec2-user
[ec2-user@ip-172-99-99-99 Weekly Report]$ touch tmp.txt
touch: cannot touch ‘tmp.txt’: Permission denied
[ec2-user@ip-172-99-99-99 Weekly Report]$ ls -ld .
drwxr-xr-x 7 jenkins jenkins 4096 Jan 28 09:00 .


I need to execute commands as the Jenkins user to troubleshoot Maven issues.







sudo users su amazon-ec2 amazon-linux






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 30 at 23:42







Chloe

















asked Jan 29 at 20:35









ChloeChloe

2401513




2401513












  • Does the jenkins user share a uid (500) with ec2-user?

    – Jeff Schaller
    Jan 29 at 20:42











  • No they don't. From /etc/passwd: ec2-user:x:500:500:EC2 Default User:/home/ec2-user:/bin/bashn jenkins:x:498:497:Jenkins Automation Server:/var/lib/jenkins:/bin/false

    – Chloe
    Jan 30 at 23:38


















  • Does the jenkins user share a uid (500) with ec2-user?

    – Jeff Schaller
    Jan 29 at 20:42











  • No they don't. From /etc/passwd: ec2-user:x:500:500:EC2 Default User:/home/ec2-user:/bin/bashn jenkins:x:498:497:Jenkins Automation Server:/var/lib/jenkins:/bin/false

    – Chloe
    Jan 30 at 23:38

















Does the jenkins user share a uid (500) with ec2-user?

– Jeff Schaller
Jan 29 at 20:42





Does the jenkins user share a uid (500) with ec2-user?

– Jeff Schaller
Jan 29 at 20:42













No they don't. From /etc/passwd: ec2-user:x:500:500:EC2 Default User:/home/ec2-user:/bin/bashn jenkins:x:498:497:Jenkins Automation Server:/var/lib/jenkins:/bin/false

– Chloe
Jan 30 at 23:38






No they don't. From /etc/passwd: ec2-user:x:500:500:EC2 Default User:/home/ec2-user:/bin/bashn jenkins:x:498:497:Jenkins Automation Server:/var/lib/jenkins:/bin/false

– Chloe
Jan 30 at 23:38











2 Answers
2






active

oldest

votes


















1














From your comment the default shell is set to /bin/false



As the user jenkins you can use chsh to change this permanently.



Alternatively if you don't want to perminantly change it you can just run bash as jenkins with:



sudo -u jenkins /bin/bash -l





share|improve this answer






























    0














    This worked.



    sudo su -s /bin/bash jenkins





    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%2f497545%2fhow-do-i-switch-users-on-amazon-linux-for-ec2-instances%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      From your comment the default shell is set to /bin/false



      As the user jenkins you can use chsh to change this permanently.



      Alternatively if you don't want to perminantly change it you can just run bash as jenkins with:



      sudo -u jenkins /bin/bash -l





      share|improve this answer



























        1














        From your comment the default shell is set to /bin/false



        As the user jenkins you can use chsh to change this permanently.



        Alternatively if you don't want to perminantly change it you can just run bash as jenkins with:



        sudo -u jenkins /bin/bash -l





        share|improve this answer

























          1












          1








          1







          From your comment the default shell is set to /bin/false



          As the user jenkins you can use chsh to change this permanently.



          Alternatively if you don't want to perminantly change it you can just run bash as jenkins with:



          sudo -u jenkins /bin/bash -l





          share|improve this answer













          From your comment the default shell is set to /bin/false



          As the user jenkins you can use chsh to change this permanently.



          Alternatively if you don't want to perminantly change it you can just run bash as jenkins with:



          sudo -u jenkins /bin/bash -l






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 30 at 23:49









          Philip CoulingPhilip Couling

          1,101817




          1,101817























              0














              This worked.



              sudo su -s /bin/bash jenkins





              share|improve this answer



























                0














                This worked.



                sudo su -s /bin/bash jenkins





                share|improve this answer

























                  0












                  0








                  0







                  This worked.



                  sudo su -s /bin/bash jenkins





                  share|improve this answer













                  This worked.



                  sudo su -s /bin/bash jenkins






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jan 30 at 23:39









                  ChloeChloe

                  2401513




                  2401513



























                      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%2f497545%2fhow-do-i-switch-users-on-amazon-linux-for-ec2-instances%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 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?