How do I switch users on Amazon Linux for EC2 instances?
Clash Royale CLAN TAG#URR8PPP
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
add a comment |
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
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
add a comment |
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
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
sudo users su amazon-ec2 amazon-linux
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
add a comment |
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
add a comment |
2 Answers
2
active
oldest
votes
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
add a comment |
This worked.
sudo su -s /bin/bash jenkins
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
add a comment |
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
add a comment |
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
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
answered Jan 30 at 23:49
Philip CoulingPhilip Couling
1,101817
1,101817
add a comment |
add a comment |
This worked.
sudo su -s /bin/bash jenkins
add a comment |
This worked.
sudo su -s /bin/bash jenkins
add a comment |
This worked.
sudo su -s /bin/bash jenkins
This worked.
sudo su -s /bin/bash jenkins
answered Jan 30 at 23:39
ChloeChloe
2401513
2401513
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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