Questions tagged [su]
su is a utility to run a shell or other command as another user (root by default).
479
questions
0
votes
1answer
13 views
Packages download defaults to be sandboxed
Why most Linux packages download defaults to be operated under sandbox canceling su privilege ?
E.g. is on debian
W: Download is performed unsandboxed as root as file ...
Please one elaborate sandbox ...
0
votes
1answer
44 views
Switching users using sudo is slow (takes several minutes)
I have a VM running Debian 9 (Stretch).
I can log in to my own user account fine.
However, every time I try to switch users using sudo su, after entering my password (instantaneously), it takes ...
0
votes
0answers
16 views
On Oracle Linux 6, I am trying to start the postgresql service and it's failing with 'runuser: /bin/bash:/sbin/nologin: No such file or directory'
Everything was working fine until this morning. The postgresql service has stopped and I can't start it.
When I run the command sudo service postgresql start, I get a [FAILED] message. Then, I go to ...
0
votes
2answers
36 views
How to pass password when switching user via su username in one line
I have an ec2 instance , I connect to it and do the following:
[userA@ip-abcd ~]$ ssh my_ec2_instance
[userA@ip-abcd ~]$ whoami
userA
[userA@ip-abcd ~]$pwd
/home/userA
[userA@ip-abcd ~]$ cd ...
0
votes
1answer
50 views
Difference between sudo -u $USER and su - $USER as non root user
How come the first one doesn't work and is not able to find conda on the PATH and the second works?
$ su - $NB_USER -c "echo $PATH && conda --version"
/opt/conda/condabin:/opt/conda/...
0
votes
0answers
17 views
/usr/bin/su question regarding setuid [duplicate]
By default, /usr/bin/su has -rwsr-xr-x privilege.
When I revoke the setuid from su file, non-root users are not able to execute su command to login as a different user.
Why is this?
Shouldn't it work ...
0
votes
0answers
30 views
Switched from bash to zsh and now I can't login as root [duplicate]
I have changed my shell from bash to zsh and set it as default in Ubuntu 20.10 and now every time I run the command su i get this:
su
Password: (entered correct password)
su: Authentication failure
...
1
vote
1answer
25 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 ...
0
votes
1answer
21 views
su Options (running a command as another user)
Hello StackExchange community,
This post relates to su options - running command as another user (however I cannot make comments yet, as I have created a profile to ask this specific question below).
...
1
vote
1answer
54 views
Linux shell script to switch user and prompt required information background to script
I need a sample linux shell script for scenario below:
During interactive session:
su user1
Password: <Type password>
What I will do is I will save the password in some file (e.g.: ~/pwd.txt). ...
0
votes
0answers
13 views
How to enable switch user rights in RHEL Linux
I am not an UNIX/Linux administrator. I got a requirement and I am trying to find a solution for the same. In my team, I got few developers who got their employee id. We want to allow the ...
0
votes
2answers
67 views
I'm not in “wheel” group, but I can “su -”
I don't understand. In BSD if I want to run su -, I have to add myself to wheel group.
Is this not true in Linux?
[test@centos ~]$ uname -a
Linux centos 4.18.0-193.19.1.el8_2.x86_64 ...
[test@centos ~]...
0
votes
0answers
21 views
SSH session gave a false negative when adding user to wheel [duplicate]
Specifications
RHEL version: Red Hat Enterprise Linux release 8.2 (Ootpa)
Kernel version: 4.18.0-193.14.3.el8_2.x86_64
The issue I was facing
Yesterday I started a SSH session to a RHEL8 machine, ...
2
votes
0answers
87 views
Solution: How come that lxc-attach doesn't work within su -c?
I have an unprivileged lxc container. It works well and if I need to do something within that container, I su --login lxc-user, then I do lxc-attach -e -n lxc-container for e. g. doing updates ...
0
votes
2answers
305 views
How do i make a program run with elevated privileges but not as root?
I am testing CTF like thing in my laptop and i have option to upload a PHP file which when executed grants shell to uploader, (reverse shell), however there is a problem. When i do
su - www-data
cd /...
0
votes
1answer
192 views
Executing sed throws the error “unexpected EOF while looking for matching”
Here's the problem.
I'm trying as "root" user to execute a command as "myusername" user.
That's why I'm using su - $USERNAME -c <command>
The <command> itself is ...
0
votes
1answer
62 views
kdesu freezes after entering password
I have Debian 10 Buster with KDE.
I can't launch any program with kdesu. After entering a root password in kdesu window, it freezes and hangs up.
How to find why? Maybe there's other ways to start ...
0
votes
0answers
118 views
Why is “sudo su” slow without ALL=(root) in /etc/sudoers?
I have had this weird issue on a SLES 12 Server.
Info:
We have lots of application users like for example applusr01, applusr02, ...
We have a special user which has sudoers rights to run commands as ...
1
vote
1answer
77 views
Right way to use su and a specific command?
When I need to, I've always done things like
su root cmd args
to run cmd as root with args. The man page used to say something about how it invoked your cmd using the target account's shell and -c, ...
1
vote
1answer
228 views
why cant I sudo cd into /root [duplicate]
when I run sudo cd /root it says sudo: cd: command not found but it works perfectly fine if I first sudo su and then do cd /root.
Isn't sudo supposed to give me root privileges?
1
vote
1answer
82 views
zsh prompt losing customization when using `sudo su`
My current zsh prompt is:
prompt='%F{013}%2~%f$(git_super_status)%(?.%F{004}.%F{001}ā%?)$ %f'
It looks something like:
Documents/multi-git-status:masterā5ā2ā1ā¦$
However, when I use sudo su it ...
0
votes
1answer
43 views
What are the differences between “sudo -s” and “su root”? [duplicate]
What are the differences between "sudo -s" and "su root"?
As they both can provide root permission.
0
votes
1answer
20 views
login with “su john” command does not source john's .bash_profile [duplicate]
The .bash_profile for user john is not taking effect when I (as root) use the su john command to login as john. I have to use source ~/.bash_profile command every time I login as john using the su ...
3
votes
2answers
5k views
Error: su: must be run from a terminal
When I try to login to root user using shell script given below, it throws an error:
su: must be run from a terminal
The srcipt (scriptfile.sh) looks as follows:
su -s <<EOF
echo Now i am root
...
0
votes
2answers
591 views
systemd — su: Permission denied, in /etc/init.d scripts
We are migrating from RHEL6 to RHEL8
and I would like to retain the old /etc/init.d scripts,
since we have a ton of applications that would otherwise
need be rewritten and tested.
For many init-...
0
votes
0answers
21 views
Ubuntu always change user
I have no idea what is the topic of my problem.
I have to change the user using su user when accessing the server with ssh user@server
The initial terminal shows just > without a user name (i.e., ...
0
votes
0answers
81 views
What happened to “su” command in CentOS 8?
I'm considering to change the user running old java programs from root to a system or normal user with low privileges, but something wrong happened with the logs permissions. The permission of logs ...
0
votes
2answers
313 views
How can I run su root and enter credentials in a script?
there's a script that I have and it needs to be run by root user. I just wanted to know how to run that script using su in the script. - I'm running CentOS7.
The command I attempted (below) failed:
su ...
2
votes
0answers
79 views
Disable root password, and eliminate sudo, on system that will only ever be orchestrated remotely?
The system in question will only ever be managed remotely using Ansible and so I'm not concerned about limiting catastrophic commands from a group of users or allowing convenient administrative access....
0
votes
2answers
1k views
Why doesn't “usermod” work under superuser?
The usermod command successfully through sudo.
sudo usermod -aG some_group some_user
However, if you execute it through su, then there will be an error.
su
...I enter root password...
usermod -aG ...
2
votes
2answers
444 views
su: Permission denied (credentials correct)
There are a lot of questions with similar titles. I believe I have checked them all before asking this question.
My error is su: Permission denied and the user switch is not completed. Here are the ...
4
votes
3answers
479 views
iptables rule to unblock internet acess, and block it again 3600 seconds later
I do this, from my son's terminal, to sometimes give him internet access (disabled by default):
./unblockinternet.sh
<enter password>
with this script:
su -c "iptables -D OUTPUT -m owner --...
0
votes
1answer
335 views
Why whoami always returning “root”?
After a hack, a dedicated server always return "root" following whoami command. Even after a sudo su myUser > whoami return "root".
myUser exists on the server, because regarding this issue passwd ...
2
votes
2answers
122 views
How to do this su + sudo in one command?
My son (not sudoer) is logged-in, and from his terminal, I sometimes want to iptables to remove the internet blocking (which will be back again after reboot ;)).
son$ su dad
<enter password>
...
0
votes
1answer
65 views
Fedora fails to start and lost shell access
Linux Dist: Fedora 31 Mate compiz.
Dual boot with win10. (UEFI secure boot enabled).
1)
While shutting down the system, an unusual errors showed up in the screen.
So the problem started with Lightdm....
3
votes
1answer
7k views
Why `su` gives “su: Authentication failure” even when running as root?
Somewhat like in How to suppress su authentication failure warning?, but it actually does not run the command at all.
# su limited
su: Authentication failure
# su -s /bin/bash limited
su: ...
-1
votes
2answers
108 views
Which one is safer? sudo dnf update OR su - ; dnf update
Is it safer to do:
$ sudo dnf update [enter user password]
or
$ su - [enter root password]
# dnf update
I always assumed they are the exact same thing, because sudo utilizes setuid-root, so the ...
1
vote
1answer
161 views
BASH Script running as root, tidy way to group commands run as another user?
I'm aware that i can run each command as a different user with:
su -s /bin/bash "command" - user
But there's several commands to run and i was looking for a neater way to do it than putting su on ...
0
votes
1answer
115 views
Able to do su into a newly created account but direct ssh is not working
I need some guidance here.
I have created a new account on the Linux server and encountered a weird problem. The new account is not able to log in and can't even ssh test@localhost I am able to ssh as ...
1
vote
1answer
78 views
Difference between su vs sudo [duplicate]
What is the difference between the two commands? Which one is better to emulate another user when wanting to do something as that user?
sudo -H -iu USER command
and
su -l USER -c command
0
votes
1answer
79 views
'su user' behavior differs when logged in locally vs via ssh
On my Ubuntu 18.04 system, there's a user called myuser without a password:
tester@box:~$ passwd -S myuser
myuser NP 03/31/2020 0 99999 7 -1
When I log in to the machine locally and switch to myuser ...
0
votes
2answers
80 views
How to solve the issue where nano screen text is scrambled when using su - admin
In Terminal I su - admin while in my user account to brew update, modify .bashrc, etc.
I have noticed that when in my user session changing the size of the window while running nano doesn't scramble ...
1
vote
1answer
98 views
sudo -u “user” --login vs. su “user” --login
I think there is slightly differencess between
sudo -u "user" --login
and
su "user" --login
For instance, I create a user with useradd -m user and ran passwd -e which means the user user's ...
0
votes
0answers
28 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....
2
votes
1answer
1k views
How to install sudo, when I don't have sudo or su
I'm operating within a Kong API Gateway Docker container, and am trying to install some basic package handling. Ultimately, I need to be able to use sudo. The Docker image comes with only busybox bin ...
0
votes
1answer
48 views
Making wheel group membership sufficient for su on SLES 2015
I'm using SLES 2015. I want to make membership in the wheel group sufficient for root-privilege access via su.
From Debian distributions, I'm used to uncommenting the command:
auth sufficient ...
0
votes
1answer
131 views
Why is pam_env.conf ignored after I su into root user?
I'm trying to do:
su -l
and set environment variables like PAGER without success. How can I achieve this?
This is what I have in /etc/pam.d/login:
auth required pam_securetty.so
auth ...
2
votes
1answer
110 views
Why does su ask for a password if stdin is redirected? How do I avoid this?
I'm using su (not interested in sudo for the purposes of this question) and observing the following behavior:
$ su USER -s /bin/bash -c "echo hi"
hi
$ printf "" | su USER -s /bin/bash -c "echo hi"
...
0
votes
1answer
1k views
How to get the command line history of another user?
I currently have a server set up to save Bash history for every user immediately in their respective home folders and I want to create a script that runs on a set interval that switches the current ...
1
vote
1answer
175 views
Can a process send keystrokes or read text to/from a tty that is running su/sudo?
I need some information regarding the possible attack vector on *nix platforms of running su/sudo.
Can an malicious process wait for the user to run su or sudo and then exploit that root access ...