Linked Questions
38 questions linked to/from Is there ever a good reason to run sudo su?
3 votes
1 answer
17k views
Deference between command "sudo su ls" vs "sudo ls" [duplicate]
I saw some command such as sudo su ls, and I just wonder what's the deference between sudo ls?
7 votes
2 answers
1k views
Difference between sudo -s and sudo su - [duplicate]
It might be a duplicate and I'm pretty sure I already saw an answer to this somewhere, but I wondered what are the differences in terms of rights and variables and other stuff between sudo -s and sudo ...
55 votes
7 answers
125k views
how to pass environment variable to sudo su
I basically need to do this: DUMMY=dummy sudo su - ec2-user -c 'echo $DUMMY' This doesn't work. How can I pass the env variable $DUMMY to su? -p doesn't work with -l.
45 votes
3 answers
138k views
This user is currently not available - but allow to run script by this user
I created special user in /etc/passwd with: secure:x:2000:2000:secure:/bin:/usr/sbin/nologin I don't want to allow login of this user (via console, ssh, ftp, any way). He is just for running one ...
8 votes
5 answers
103k views
How to access another user's folder from another user account
I have some downloads in my root user /root/Downloads folder. How can I access them from another not-root-user account?
9 votes
1 answer
35k views
sudo su in bash error "Cannot execute help: No such file or directory"
I installed zsh and changed root shell /bin/bash to /usr/bin/zsh. Then I rebooted and typed sudo su. It said "Cannot execute help: No such file or directory". So, I typed sudo bash. However, when I ...
11 votes
5 answers
11k views
What's the difference between sudo su vs just su?
I see a lot of posts out there that say you type in sudo su to get an interactive prompt with root privileges, and I see equally many posts debating the pros and cons over sudo -i vs sudo su. Here I'...
9 votes
2 answers
2k views
How does bash file redirection to standard in differ from shell (`sh`) on Linux?
I wrote a script which switches users while running, and executed it using file redirection to standard in. So user-switch.sh is... #!/bin/bash whoami sudo su -l root whoami And running it with ...
5 votes
1 answer
13k views
How can I have a root login shell with sudo?
My user is part of the admin group and I'm used to type sudo su to impersonate root. Unfortunately this generate a non-login shell and if I need one I need to type again /bin/bash -l. Is there any ...
2 votes
2 answers
16k views
Allowing `sudo su` without password over Ubuntu [duplicate]
This question is answered a number of times in the net, but none of those answer resulted useful in my case. The problem Accessing a remote machine using private key, I usually require root ...
5 votes
3 answers
3k views
Run script with arguments as user
I am trying to make sure when a script is run it is run as a specific user without having to su to that user before the script is run. Also the script is run with a couple of flags for example ./...
1 vote
2 answers
5k views
Does it make any difference to create ssh key as root or as user?
I want to create a ssh key, I wanted to know does it make any differences when I create the key as root and when I create it as user? like as a user I do this: ssh-keygen -t rsa -C "your_email@...
1 vote
2 answers
11k views
sudo su - anotherusername not prompting for password
I using Redhat linux. I am trying to run the following command and would like to know why it is not prompting for password? Here is what I am doing. I open the terminal window and enter my username ...
5 votes
2 answers
6k views
When can a user do `sudo su` but not `sudo su -`?
The following happened to me: $ sudo su - superman Sorry, user clarkkent is not allowed to execute '/bin/su - superman' as root in krypton101. However the following worked fine: $ sudo su superman ...
1 vote
3 answers
6k views
proceed execution of script after change user
I want to continue the execution of the script after change user, the script would be something like below echo "xauth add" `xauth list | grep ${DISPLAY:10:2}` >> test.sh sudo su ./test.sh ...
0 votes
2 answers
7k views
root password not working but can ssh via sudo user (centos)
I can use RSA keys to putty into my centos VPS with no problem. And from there I can use sudo to run commands. But my root password is not working. I wonder if I hosed something while setting up ...
4 votes
1 answer
16k views
"sudo: unable to allocate pty: No such device" in chrooted Linux
Added: After reading suggested as duplicate Which of proc, sys etc. should be bind-mounted (or not) when chrooting into a "replacement" distribution? : How I know: it is customary to invoke ...
3 votes
1 answer
9k views
Does "sudo su" makes me the root user?
I have typed sudo su in the Terminal, and then I typed whoami, and the Terminal said that I am the root user. So does that mean that sudo su makes me the root user or am I missing something?
2 votes
2 answers
2k views
Executing Alias Command as Another User Fails
Not sure what I'm doing wrong here. User2 sources a file in it's .bash_profile to set environment specific aliases. # .bash_profile source $HOME/set_environment_shortcuts Inside $HOME/...
3 votes
1 answer
4k views
Command not found when run as sudo
I'm running centos7. I installed puppet. if I write puppet as a user, I get a proper output. If I write sudo puppet I get command not found. The really weird thing is, if I do sudo su - and become ...
2 votes
1 answer
2k views
Why can I run `sudo bash` but not `sudo su`?
I am working on standardizing the sudo access in our environment. To begin with, I am understanding the current setup. Currently, we use sudo bash to get into the root shell without typing any ...
0 votes
1 answer
1k views
bash - su and $HOME
Assume we have two users: user1 (an admin) and user2 (a standard user) Login as user1 Run sudo su - user2 -c "env" The result shows $HOME=/home/user2 Run sudo su - user2 -c "echo $HOME" The ...
-1 votes
2 answers
3k views
sudo execute as other user with parameters
I created a (system) user, eg: mysysuser, and some sudo rules so it can do some maintenance in other users folders. This script needs to run as other user but also needs some parameters. Therefore, ...
0 votes
1 answer
2k views
Login incorrect on Centos 7 [duplicate]
I can login as any user, but not as a root user in centos 7. When I type the command su and enter password ,it gives me login incorrect message. What could be the issue?
1 vote
1 answer
2k views
SUDO_* environment variables not set when using sudo su -
I have a use case where I want to sudo su - user1 to some user and then run script and in the script I want to fetch SUDO_USER. However the SUDO_* environment variables do not get set when I use sudo ...
3 votes
1 answer
471 views
sudo results in a new session with a new controlling PTY
On Linux Ubuntu when at terminal I run sudo su or sudo su - the system creates a new session with a new controlling pts, namely ubuntu@ubuntu:~$ lsb_release -a No LSB modules are available. ...
0 votes
0 answers
1k views
Is it secure to inject a password from a batch script variable in Windows to a SSH command run on Linux?
We are thinking of using a batch file as shown below for our software deployment. While we don't need high security we are still wondering if there are obvious security issues with this approach. @...
0 votes
1 answer
734 views
Account's password won't let me sudo
I want my server to not allow root login. For this I want to set the PermitRootLogin to No (in the SSH daemon config), but before doing that I want to make sure I can switch to root from another user ...
1 vote
1 answer
287 views
What are difference between -bash and bash?
When I log in as root and enter some random non-existing command, it says: root@localhost:~# asdf -bash: asdf: command not found root@localhost:~# But when I do the same thing as user rakinar2 it ...
0 votes
1 answer
468 views
How can I get root permissions with running "sudo su -" instead of "/tools/xgs/bin/sudo su -"?
Currently I am running a server on vnc with RHEL 7 operating system. Background: I login to the server say kpod@server1 Now when I need to access root permissions. I use the path /tools/xgs/bin/sudo ...
0 votes
0 answers
423 views
SSH to machine and change user to root
I am trying to SSH a remote machine and change user to root and run a series of command which need root I tried the command below but seems it's not working sshpass -p <pwd> ssh -q -o ...
0 votes
1 answer
182 views
looping array inside shell script with a different user using HEREDOC doesnt work
I want to perform the set of actions inside a different user while running my script, so i am using HEREDOC to perform such actions, but no matter alternatives i try, i cannot able to reference my ...
2 votes
0 answers
520 views
How to automate Ansible SSH login with Duo MFA for sudo access
The problem: I'm trying to run Ansible on a Mac to remotely configure a linux (ubuntu) server that requires MFA access for sudo usage. My goal is to keep the MFA in place (as required by our security ...
-2 votes
2 answers
154 views
Environment Variable and PATH issue
I tried to set an environment variable for the Sublist3r tool and messed up. Now whenever I switch to the root user (with sudo su) the only command I am able to use is exit (attaching the images). I ...
1 vote
1 answer
218 views
how to set environment vars (PS1) when using su - user [duplicate]
Working on Ubuntu (but I doubt it matters). Our Unix servers are set up so users (read admins) have to login to their personal accounts. If you need to work as an other (say application user) you ...
0 votes
0 answers
126 views
`su -c "command" user` fails while command succeeds
this command fails when it is being run by a user that is different from myuser and having sudo rights: sudo su - -c "export KAFKA_OPTS=-Djava.security.auth.login.config=/etc/kafka/conf/kafka_jaas....
1 vote
1 answer
99 views
Sudo vs Su with specific usage on Debian
Are: sudo -i and su - functionally the same, both should give fresh root shells with root's environment right? If so are sudo -s and su the same? Thanks
-1 votes
3 answers
219 views
How to ssh, su , maintain the session and make effects only to my session environment?
I want to SSH into a remote server (Amazon Linux 2) and simultaneously execute su and some commands, while also maintaining the SSH session in a single script like this: ssh -t ec2-user@$host -i $...