Questions tagged [su]

su is a utility to run a shell or other command as another user (root by default).

Filter by
Sorted by
Tagged with
0 votes
1 answer
18 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 ...
user avatar
  • 213
2 votes
0 answers
54 views
+50

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 ...
user avatar
  • 18.3k
0 votes
1 answer
35 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 ...
user avatar
  • 339
0 votes
1 answer
58 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 ...
user avatar
1 vote
1 answer
32 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 ...
user avatar
  • 10.9k
0 votes
1 answer
31 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 ...
user avatar
  • 199
0 votes
1 answer
36 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 ...
user avatar
  • 56
0 votes
0 answers
86 views

Linux shell command : su authentication failed

I upgraded current OS to latest version. i am unable to do su from admin to root user. I checked /etc/password, /etc/shadow, unix_chkpwd and su permission, everything looks ok i dig into the /etc/pam....
user avatar
1 vote
1 answer
78 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 ...
user avatar
  • 181
0 votes
2 answers
238 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-...
user avatar
1 vote
2 answers
70 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 ...
user avatar
-1 votes
2 answers
88 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 ...
user avatar
2 votes
2 answers
1k 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 ...
user avatar
  • 123
0 votes
0 answers
60 views

Interrupting rsync crashes a container

Consider the following script (/tmp/a.sh). It prepares an environment to run rsync: #!/bin/sh -eu docker run --rm -it \ -v /:/host \ alpine sh -c ' apk add rsync shadow procps ...
user avatar
  • 2,893
0 votes
2 answers
65 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: ...
user avatar
  • 5
0 votes
1 answer
39 views

force update groups - su self wont work - non root - only have ssh login

System administrator added me to a group but I don't see the effects yet. For example, > groups # does not return the desired group I (and all other users) only have the ssh login option to ...
user avatar
0 votes
1 answer
124 views

How do I use su to execute the rest of the bash script as that user?

I have a bash script my_script.sh created as a root user that has a part where it has to be switched to a sudo user. I have tried heredocs and it's working, but the issue with it is I can't use ...
user avatar
  • 77
0 votes
1 answer
228 views

How to system-widely configure kdesu to use sudo instead of su (KDE Plasma)?

I'm trying to make kdesu use sudo instead of su. I know that this is possible to achieve by creating a local kdesurc file by running kwriteconfig5 --file kdesurc --group super-user-command --key super-...
user avatar
  • 148
4 votes
2 answers
3k views

How can I su to a user with no login shell?

Problem In Debian 10 I want to create a user who cannot log in directly. One should only be able to access the user by using the su binary. In my Ubuntu 18.04 setup, I did exactly this and it worked ...
user avatar
1 vote
2 answers
101 views

List users who have become root via "su" in last 30 days

How do I get the history of the users who have used su command to become root in Linux (in my specific case SuSe)?
user avatar
0 votes
0 answers
35 views

Allow an authentication (setuid) script to use "su" but disable it for any user

I'm only allowing ssh login for 1 central user on my system. Right after the login there will be an executable running that basically authenticates a user in a 2fa way. The executable asks for a ...
user avatar
0 votes
1 answer
73 views

su not working inside arch-chroot with dash shell

When i try to do the following inside a dash script: #!/bin/dash arch-chroot /mnt /bin/dash <<- EOF su myuser whoami EOF It simply logs the "root", but when i try to do it ...
user avatar
0 votes
1 answer
607 views

Restrict user to switch to root user but have all commands to execute

I want to provide a user to execute all command what a root user can do except from switching to root user. SO I added as below in sudoers file in centos7/redhat7 guest ALL=(ALL:ALL) NOPASSWD: ALL,!/...
user avatar
  • 213
0 votes
0 answers
79 views

How to make KDEsu take root password instead of user password

I have just installed Devuan with KDE, and I have been unable to change certain settings graphically. I do have a root user enabled, and for certain tasks, KDE will ask for my root password, which ...
user avatar
1 vote
2 answers
215 views

Running a Command With Another User's PATH Variable

Ubuntu 20.04.2 LTS The problem I have is with running commands as another user (sudo/runuser/...). I'm unable to find a set of options for any of them that run the command with the target user's $PATH ...
user avatar
  • 11
0 votes
1 answer
671 views

sudo ssh: load pubkey Permission denied

user1 needs to be able to su to user2 on host1, and then ssh to host2 using public key authentication. The key is in /home/user2/.ssh/id_rsa on host1. It works with sudo -s... [user1@host1] $ sudo -u ...
user avatar
2 votes
0 answers
62 views

Is there any difference between Ubuntu and Centos 7 when running su -c “my command” “someuser” ?

I tried below command in both Ubuntu and Centos 7: su -c "./bin/server" swrun and I found it's started process by root in Ubuntu, but started process by swrun in Centos 7. I used service ...
user avatar
13 votes
2 answers
2k views

Why do all users start in /root instead of their home directories after su as root?

I feel like this should be straightforward but I've never seen anyone ask this that I can tell. The situation is pretty straight forward. Whenever I become a user, ie su user it always starts in /root ...
user avatar
0 votes
1 answer
37 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 ...
user avatar
1 vote
1 answer
233 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 ...
user avatar
  • 113
0 votes
1 answer
130 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 ...
user avatar
0 votes
2 answers
645 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 ...
user avatar
0 votes
1 answer
182 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/...
user avatar
0 votes
0 answers
35 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 ...
user avatar
1 vote
1 answer
247 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 ...
user avatar
  • 111
0 votes
1 answer
28 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). ...
user avatar
  • 1
1 vote
1 answer
116 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). ...
user avatar
0 votes
0 answers
21 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 ...
user avatar
0 votes
2 answers
335 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 ~]...
user avatar
2 votes
0 answers
277 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 ...
user avatar
0 votes
2 answers
708 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 /...
user avatar
0 votes
1 answer
579 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 ...
user avatar
  • 111
0 votes
1 answer
157 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 ...
user avatar
  • 1
0 votes
0 answers
523 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 ...
user avatar
2 votes
2 answers
327 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, ...
user avatar
1 vote
1 answer
2k 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?
user avatar
1 vote
1 answer
420 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 ...
user avatar
  • 1,181
0 votes
1 answer
99 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.
user avatar
  • 218
0 votes
1 answer
26 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 ...
user avatar
3 votes
3 answers
16k 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 ...
user avatar

1
2 3 4 5
11