Questions tagged [su]
su is a utility to run a shell or other command as another user (root by default).
537
questions
0
votes
2
answers
66
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
83
views
Execute a virsh command as another user in interactive setup script
I am using a script to setup some Fedora machines and I can not execute a Virsh (cli tool for Libvirt) command as another user. The output given indicates that the command was successful but it fails ...
0
votes
0
answers
31
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
42
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
60
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
287
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
121
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
101
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
117
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
30
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
72
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:
...
-3
votes
1
answer
109
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
0
votes
0
answers
35
views
psub creates temp file as 'root' when fish is running under different user
Running the following from within a Docker container:
su postgres -s /usr/bin/fish -c "
echo 123 > /tmp/mypass
stat /tmp/mypass
stat $(echo 123 | psub)
"
Output of echo:
File:...
5
votes
1
answer
691
views
How to make typing passwords visible?
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
0
answers
2k
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
106
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
702
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.
0
votes
1
answer
59
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
83
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
4k
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
0
answers
16
views
Passwordless user switching not working
I have the following line in /etc/sudoers.d/custom
myuser ALL=(foouser) NOPASSWD:ALL
However:
myuser@ip-10-123-9-1:~$ sudo su - foouser -i
[sudo] password for myuser:
Why is it asking me for ...
0
votes
1
answer
37
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 ...
2
votes
2
answers
845
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
317
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
122
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
685
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
155
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
63
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 ...
0
votes
0
answers
1k
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
376
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
503
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
199
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
1k
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
259
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
154
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 ...
3
votes
1
answer
1k
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
112
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
165
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
519
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
2k
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
258
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 ...
0
votes
1
answer
306
views
Same user after switch user command (su - mysql --> whoami 'old_user'), why?
I am trying to switch the user in my shell with su - [user], but the user seems to remain the old one:
# this works pretty well
bodo@bodo-work:~$ sudo -u mysql whoami
[sudo] password for bodo:
mysql
...
0
votes
1
answer
187
views
pkexec with >> directing output to file
If I try
pkexec echo -e '\nwl2k something\n' >> /etc/ax25/axports
in terminal to have a user add a line to a file, I get a
bash: /etc/ax25/axports: Permission denied
How do I make it so the ...
1
vote
1
answer
868
views
Failed to Switch User?
On machine A and B (both running CentOS 7), I have:
# cat /etc/sudoers.d/custom
userA ALL=(userB:userB) NOPASSWD:ALL
However, on machine A, when I run
[userA] $ sudo -ui userB
sudo: unknown user: i
...
0
votes
2
answers
1k
views
How to run an X app (vscode) as another user
Essentially what I want is to run vscode without giving it permission to read my home directory.
So I created a new user vscode and downloaded the .tar.gz file from https://code.visualstudio.com/#alt-...
1
vote
2
answers
414
views
Why does openssl create different hashes for the same string, and how does linux accept the different hashes when switching users?
Background
As an experiment, I was adding new users (as the root user) by manually creating entries into /etc/passwd. To hash the passwords I was using openssl, in particular OpenSSL 1.1.1g but the ...
-1
votes
2
answers
188
views
xsel not recognized after "su - other-account" [duplicate]
I am new to Linux and have set up the following version of Ubuntu as a VirtualBox VM using this process:
ubuntu-20.04.3-desktop-amd64.iso
The first account created was a administrator account. I ...
5
votes
3
answers
9k
views
X11 connection rejected because of wrong authentication
First of all what I want to do:
I want to login to a server via ssh. Then change change the user via sudo su user and start some application on my screen.
Some collegues do it by
su user
export ...
0
votes
2
answers
443
views
command found from "su -" but not from "su root"
OS: Debian 10.10
I search to understand why the "usermod" command run when I launch with "su -" but when he is launched from "su root" the command is "bash: usermod: ...