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
56 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
26 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
0 votes
0 answers
60 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
134 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 ...
  • 1,631
0 votes
0 answers
27 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 ...
  • 111
0 votes
0 answers
64 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 ...
  • 7,703
1 vote
1 answer
64 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 ...
  • 11
0 votes
1 answer
35 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....
  • 65
0 votes
1 answer
73 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 ...
0 votes
1 answer
123 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 ...
  • 83
0 votes
1 answer
44 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 ...
  • 157
1 vote
0 answers
54 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 ...
1 vote
0 answers
206 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 ...
  • 177
0 votes
1 answer
37 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 ...
  • 233
3 votes
0 answers
94 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 ...
  • 19.4k
0 votes
1 answer
107 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 ...
  • 369
0 votes
1 answer
156 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
71 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 ...
  • 11.2k
0 votes
1 answer
111 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 ...
  • 209
0 votes
1 answer
71 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 ...
  • 56
0 votes
0 answers
359 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....
1 vote
1 answer
276 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 ...
  • 191
0 votes
2 answers
458 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
137 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
116 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 ...
2 votes
3 answers
3k 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 ...
  • 123
0 votes
0 answers
94 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 ...
  • 2,963
0 votes
2 answers
117 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: ...
  • 25
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 ...
0 votes
1 answer
185 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 ...
  • 87
0 votes
1 answer
369 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-...
  • 166
4 votes
2 answers
6k 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 ...
1 vote
2 answers
243 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)?
0 votes
1 answer
98 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 ...
0 votes
1 answer
978 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,!/...
  • 213
2 votes
2 answers
598 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 ...
  • 21
0 votes
1 answer
894 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 ...
2 votes
0 answers
65 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 ...
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 ...
0 votes
1 answer
55 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 ...
's user avatar
1 vote
1 answer
465 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 ...
  • 113
0 votes
1 answer
174 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
2 answers
1k 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
1 answer
278 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
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 ...
1 vote
1 answer
425 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 ...
  • 111
0 votes
1 answer
51 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
1 vote
1 answer
366 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
0 answers
39 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
2 answers
614 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 ~]...

1
2 3 4 5
11