Questions tagged [su]
su is a utility to run a shell or other command as another user (root by default).
544 questions
0
votes
1
answer
37
views
User added to wheel group, but can't su without password authentication
On a SLES 15 SP1 system, I've added a user to the wheel group:
wheel:x:1003:joeuser
however, when joeuser logs in as themselves, then tries to su (to become root), they are asked for their password. ...
1
vote
0
answers
33
views
Processes launched from "su -" are not closed when killing terminal
I have a question regarding the processes launched via a SSH session, after having performed a su - user. My question applies to RHEL 8, but might as well to other O/S. The SSH connection is initiated ...
1
vote
2
answers
1k
views
Superuser and Sudo not working on Debian 12
I recently switched from Windows to Linux, more specifically to Debian 12. I'm struggling a bit because there are a lot of new things, like sudo. Anyway, I'm basically trying to put my regular user as ...
0
votes
0
answers
48
views
is it problematic to disable 'session optional pam_systemd.so' in etc/pam.d/common-session/ to execute one line to speed up boot time?
At boot im running following command:
su vis -c 'QT_QPA_PLATFORM=offscreen /usr/bin/browser --version'
/usr/bin/browser being a custom browser, which cannot be run as root. The script that is ...
-2
votes
2
answers
255
views
runuser: execute commands without use of quotation marks?
Overview
I'm attempting to execute commands as a different user without using quotation marks as well as making sure the executed command isn't inheriting environment from the parent shell.
runuser ...
-2
votes
1
answer
182
views
Error in command su
I am creating a command that will change a certain line in the /etc/profile file from a script, however in certain versions of Linux the sudo command may not be activated so it would be necessary to ...
0
votes
2
answers
67
views
My user account is no longer a su, and I don't know the root password. What are my options?
In Kubuntu 23.10, while updating my account photo in the System Settings > Users GUI, I must have accidentally changed my account type from Administrator to Standard, as I'm no longer a su. I guess ...
0
votes
1
answer
111
views
How to programmatically determine whether superuser elevation is necessary to invoke code?
When providing code to another, it appears to be good practice to remove all elevation-specific code — that is, provide apt update rather than sudo apt update (or su -c 'apt update'). However, this ...
0
votes
1
answer
1k
views
Starting QEMU as another user
I'm currently trying to intercept/block specific requests from the guest in QEMU.
According to this question, it seems that the easiest way to do so is to run QEMU as a different user, so that I can ...
0
votes
0
answers
41
views
I typed su <user> and my terminal didn't respond. Now I don't know how to exit, ctrl+D doesn't work
I didn't check if su was blocked so I directly typed su <user>, and then nothing happened except that it "loaded"... however, it didn't give me access to a new line, instead I'm stuck ...
0
votes
0
answers
134
views
sudo -i is behaving differently than sudo su -
If I as a non-root user (but in the sudoers file) do sudo -i, I get root privileges:
laptop:~$ sudo -i
[sudo] password for bjmgeek:
laptop:~$ whoami
root
laptop:~$ id
uid=0(root) gid=0(root) groups=0(...
0
votes
2
answers
607
views
What is the proper way to su as a local user from Udev?
When running commands related to displays, it seems that commands like xrandr don't work until they are run as a local user.
However, when running scripts as a local user via a udev rule:
SUBSYSTEM==&...
0
votes
0
answers
32
views
Why root user needs `sudo` to execute some commands [duplicate]
When I switched to root user using su command, I still need to use sudo reboot instead of reboot to reboot the system, otherwise bash returns
bash: reboot: command not found
Why is that the system ...
0
votes
2
answers
90
views
How does su detect fakeroot?
If I run su, it asks for the password of the target user. If i run it as root, it does not ask for a password. But if I run it in fakeroot, how is it possible that it will ask for a password? Should ...
1
vote
1
answer
96
views
How to prompt "su" to re-request a password on an incorrect entry?
Default su behaviour :
system@sword:/etc/pam.d$ su - test
Password:
su: Authentication failure
<su exits>
I need to configure "delay" when someone enters an incorrect password for ...
7
votes
2
answers
5k
views
Does "sudo" rely on "su" in any way?
I want to prevent the users from using the su command, and so I blocked the command in /etc/sudoers file as below:
%group ALL=(ALL:ALL) NOPASSWD:!/bin/su
But with this rule in sudoers, they are ...
1
vote
2
answers
2k
views
How to sudo to admin user after SFTP connection
I have a requirement to sudo to user 'admin' after connecting to SFTP server with below command.
sftp user@hostname
sftp> sudo su - admin
Invalid command.
Is there any other way I can use sudo?
0
votes
1
answer
460
views
Allow multiple user groups to "su" to multiple other users without password
I want a specific group of users to be able to use the su command as a specific user.
example)
Group
User
allowsu_aa
aa
allowsu_bb
bb
allowsu_cc
cc
So I added the below to /etc/pam.d/su file.
...
0
votes
1
answer
199
views
Alias for the "su" Command
BASH SHELL; DEBIAN STRETCH
As seen here, I've created a "seems to work OK, most of the time" alias function for the su command (actually, I'm not able to find any problems with it...yet). I'...
-1
votes
2
answers
306
views
How does using sudo instead of su improve the security level?
Edit::
With the help of people, I realised I misunderstood the text and thought the creators Ubuntu also created sudo, which is not the case! So the question should be something like how forcing ...
0
votes
1
answer
31
views
variable contains $, expansion needed
The script fetches the path of a file via some command and then the mount command runs.
pkgname= #defined here
su -c "apkfile= #defined here &&\
stockapp=$(pm path $pkgname | sed -n '/...
-2
votes
1
answer
143
views
Having problems to become root
I'm trying to become root, a thing that worked perfectly some days away and now won't work. I type in the terminal
su -sudo
then the system ask me about the password, and then appears this message:
...
-2
votes
1
answer
258
views
How to setting Ubuntu sudo password dialog for every 1 hours [duplicate]
i work on my personal Desktop that no one touch it.
so, i mean, duration password needs to be entered again after entering corect pasword.
how to do that? thx
5
votes
1
answer
1k
views
How to make typing passwords visible? [duplicate]
When sudoing in terminal a user has to type password to gain root privileges. While typing what I am typing is not visible at all. I have mental disabilities so I often forget which character I was on ...
1
vote
1
answer
5k
views
/usr/bin/id: cannot find name for user ID
When I am trying to su to a user I get errors that the names for associate group and user IDs cant be found.
The when I id the same user (while logged in with it) it says no such user
But when I id ...
0
votes
1
answer
183
views
Pass file descriptor through su -c
Given a file descriptor fd open in c program A, I want to start program B with fd open as U2. On my system (wsl2 ubuntu), execl("/usr/bin/su", "su", suarg1, "U2"); (where ...
0
votes
2
answers
1k
views
How can I return to my user's home directory after becoming root?
How can I switch from user to root? In my terminal I typed in
su -
and it took me to the root directory, so I need to go back to the user directory.
1
vote
1
answer
78
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
0
votes
1
answer
512
views
Run two commands with the same argument, on one line
I need to parse a file line by line and pass a value found in them to 2 commands, in FreeBSD's sh (no other shells can be used).
My plan was to use xargs and su:
whatever_outputs_values | xargs -I {} ...
1
vote
2
answers
15k
views
I cannot access /root directory
I have Ubuntu installed in my Mac, not on VM but as a second OS.
When I open my terminal, my username is ubuntu, instead of root.
so it become ubuntu@nadia-ubuntu:/$
Then I try to get into root ...
0
votes
1
answer
55
views
Allow users to passwordless su to more than one user
Assuming I want user1 to be able to passwordless su to someuser, I add to /etc/sudoers.d/custom
user1 ALL=(someuser) NOPASSWD:ALL
What is the syntax to also allow the same for anotheruser?
Following ...
3
votes
2
answers
2k
views
Why can't I su to root via ssh?
I've set up two VMs with exactly the same image (debian-11.3.0-amd64-netinst - headless).
The only things I touched on these machines are:
Root password
Sysad password
Installed sudo command
Changed ...
0
votes
1
answer
593
views
sudo and su root broken
I cant seem to get either sudo to work or my root to work.
i thought it was related to me changing the default shells or forgetting the root password but i rest the root password and changed the ...
0
votes
0
answers
188
views
How to switch from root to my unix user and solve (code .) command issue?
When I open ubuntu(wsl) on windows , usually, it opens as karim_123 user and not as root user. But this time it opened as a root user. How can I return back to my unix linux account(karim_123)? I used ...
1
vote
0
answers
1k
views
command whoami and echo $USER are giving different outputs how is that even possible?
If I don't fix this I can't properly run bash scripts that checks whether the $USER is root in an IF statement, because, as it is, the $USER is never root, even when the whoami is the root. No matter ...
2
votes
1
answer
404
views
Restrict User Functions to only "su" to other users
I have a server running on CentOS 7 that have 100 user each user with restricted access to its home dir. I want to create a user that only able to su to one of these other users, where all other ...
0
votes
0
answers
71
views
su cannot find script in path
On AWS EC2 instance I have the following script that runs at startup under the root user
cd /home/ec2-user/lutze
su -p -c "python -m lutze" ec2-user
The script runs without a problem ...
1
vote
0
answers
3k
views
Fix dconf-WARNING **: failed to commit changes to dconf - in non-login su session
I've read this:
dconf-WARNING **: failed to commit changes to dconf: The connection is closed
... and I have the same problem. But - I don't like the solution. I want to run a non-login root shell ...
1
vote
1
answer
675
views
Errors when changing user
Every time I use su myName to change my user, I always get these 3 errors.
-bash: zstyle: command not found
-bash: autoload: command not found
-bash: compinit: command not found
It only happens when ...
0
votes
1
answer
1k
views
useradd -p option [duplicate]
I can't understand the purpose of -p option in 'useradd'
Let's create a user
useradd -m -p 'pass1' user1
after running the command above, when trying to log in using su - user1
authentication fails....
0
votes
1
answer
514
views
Use "sudo su" but avoid having root as file owner
I have a long script which I want to execute, a lot of commands in the script need sudo.
To avoid using sudo, I put sudo su at the beginning of the script.
The problem with this is that this makes all ...
2
votes
1
answer
2k
views
su: cannot set user id: Invalid argument
I'm trying to create a new user and enter into it, under my Linux SUSE SLSE12 machine. I'm root on that machine. The set of commands:
> whoami
root
> useradd -u 123456 new_user
> id new_user
...
0
votes
1
answer
382
views
Exporting environment variable to user after login via su
I am struggling to work out what exactly the following alias does. I guess it is making the environment variable COUNTER available to the user nobody but the COUNTER=${COUNTER} preceding the ssh and ...
1
vote
0
answers
262
views
whoami command fails after running /bin/su
I have a system with an init script that launches multiple applications, each under it's right user and group. The init script checks the home directory of each user and looks for the application init ...
10
votes
1
answer
3k
views
Why isn't a systemd user session started by `su`?
When I use ssh to log in to the root user on my server, an entry 0 is created in /var/run/user because pam_systemd tells systemd-logind to do this. This is an indicator that a user session has been ...
0
votes
1
answer
150
views
curl pipe script forks a new Terminal window
I have a script which unexplainably forks a new Terminal instance on some Linux distributions... I'd rather it doesn't do this. Oddly, when I run the script directly (./install.sh) the additional ...
3
votes
0
answers
210
views
Alternative to "gksu" in "su" mode for non-root users
On an Oracle Linux 8 installation, I am trying to implement a desktop launcher for the GNOME shell where the (graphical) program is to be run as a different (non-root) user. However, I want to enforce ...
0
votes
1
answer
786
views
" sudo su - " is switching the user but files are getting created with parent id
We have one bash command with one user "useradm" which runs a command as
sudo su - platfrmapi; sh script.sh
sudo su - platfrmapi; cp script.sh script_2.sh
The user-switching is happening ...
1
vote
1
answer
3k
views
How do I login as the root user?
I installed Debian a day ago and I'm very new to Linux please forgive me if I miss something obvious but:
whenever I use sudo command it asks me for the current user password but the current user ...
1
vote
1
answer
361
views
A question about sudo and pass the password to command
Most user said is easy to pass password for sudo command using this cli
sudo -S <<< "yourpassord" yourcommand
or
echo "yourpassword|yourcommand
Those cli works for a lot of ...