Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [su]

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

0
votes
1answer
14 views

Open a tmux session and then change to different user without password prompt

I am trying to create a script that opens a new tmux session and then runs a command inside that tmux session as a different user. The purpose of this is to create a new tmux session for a game ...
-1
votes
2answers
48 views

What is the root password for raspbian jessie or debian 9

What is the default root password for raspbian jessie or debian 9? I have Raspbian Jessie stretch iso "Raspberry Pi Desktop" or pixel Virtualbox and I need to install keys with root "su", what is the ...
1
vote
0answers
27 views

su - <username> hangs if I added a line in /etc/bashrc

I added this line to /etc/bashrc file export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/glibc-2.14/lib I log in as root throw SSH normally, but if I wanted to change my user by su - myusername the ...
-1
votes
1answer
37 views

Not able to switch to root user via command line [duplicate]

On my centos 7 vps server, to secure my server I disabled root login via ssh. I created a new user called erdem and login with that user via ssh. After I login via ssh with user erdem, I would like to ...
0
votes
2answers
51 views

Run command from sudo su

On a machine I (tlous) have been given access to open a shell as another user (serviceAccount) Executing: sudo su - serviceAccount has the desired effect of opening a shell as this serviceAccount ...
20
votes
1answer
2k views

What does 'script /dev/null' do?

Every time I log into a VM with root, su into a user account, and try to use screen it throws an error: Cannot open your terminal '/dev/pts/0' - please check. A Stack Overflow post said I needed to ...
0
votes
0answers
15 views

what is the difference between `sudo su - <username>` and `sudo -iu <username>` [duplicate]

they both log you in as <username> and that the first involves using running su as root while the second does not involve the su command but I am wondering what are the differences to both? is ...
0
votes
0answers
24 views

Add all users in AD-Group to the local wheel group

We have limited 'su' to users that are in the wheel group and are now looking to permit certain users that are in a particular AD-Group. The users that we want to permit to use the program 'su' are ...
1
vote
2answers
51 views

How to list users that have su'ed to different accounts

I'm trying to figure out a quick & easy way to see a list of everyone's effective user id... I would have thought 'w' or 'who' would be able to display if someone had switched user accounts... but ...
1
vote
2answers
94 views

sudoers file not being used

In this shop root access is being handed out in a way that I'm not familiar with. See below. I have all the access I need, I was just wondering why the sudoers mechanism is not being used. I have to ...
1
vote
0answers
24 views

lastb output empty even after 3 failed login (su) attempts

On one terminal root@Andromeda:~# lastb btmp begins Sat Mar 2 10:03:44 2019 On another one: $ sudo su - [sudo] password for pkaramol: Sorry, try again. [sudo] password for pkaramol: Sorry, try ...
0
votes
2answers
184 views

root “su - <user>” got permission denied (Ignored)

Got permission denied when switching user from root to postgres. No issue switching from root to ubuntu. root@node-01:~# su - postgres su: Permission denied (Ignored) postgres@node-01:~$ logout root@...
0
votes
2answers
98 views

su - user not landing in users home directory

One one system when I run su - otrs the returned prompt looks like this: [root@some_server admin_app2]# su - otrs Last login: Thu Jan 31 10:47:37 CET 2019 on pts/0 [otrs@some_server ~]$ On another: ...
0
votes
0answers
28 views

su does not work in rescue.service for ExecStart

The default value of ExecStart in /lib/systemd/system/rescue.service is: ExecStart=-/bin/sh -c "/sbin/sulogin; /bin/systemctl --job-mode=fail --no-block default" This doesn't work if your root ...
0
votes
2answers
136 views

How do I switch users on Amazon Linux for EC2 instances?

I saw How to change to normal user in the command line when logged in as the root user? How to switch between users on one terminal? I have access to sudo. I tried [ec2-user@ip-172-99-99-99 Weekly ...
0
votes
0answers
17 views

Switch user providing own password

While switching to a privileged user, we enter the privileged user's password. Can I use my own password instead? Current flow: user1 -- > serviceAcctUser (serviceAcctUser password) Required: user1 -...
1
vote
1answer
90 views

What is logging in?

From https://unix.stackexchange.com/a/489913/674 Logging in is a user-space construct; the kernel doesn’t care about that. There are multiple examples of this; for example, cron jobs can run ...
1
vote
0answers
616 views

Keep getting “standard in must be a tty” [closed]

I have searched on this error and have seen responses about requiretty adn visiblepw. I have verified and set using visudo that Defaults !requiretty is set. I have even commented out Defaults !...
0
votes
2answers
445 views

How to pass multiple parameters to su <USER> -c “command”

I want to execute composer as non root user. So I renamed main composer executable file to composer-call and then create another executable file called composer. #composer.sh su nginx -c "composer-...
1
vote
1answer
509 views

“su user” does not work on CentOS 7

I have a new CentOS server. This is server uname info: [root@server ~]# uname -vr 3.10.0-862.14.4.el7.x86_64 #1 SMP Wed Sep 26 15:12:11 UTC 2018 [root@server ~]# When I try to change user using ...
-1
votes
3answers
391 views

Cannot open xterm as another user : Xt error: Can't open display: :0

I'm trying to open an xterm as another user : $ su - sebastien $ xterm No protocol specified xterm: Xt error: Can't open display: :0 $ exit $ sudo su - sebastien $ xterm No protocol specified xterm:...
1
vote
1answer
89 views

Capturing scrot command output with su

I want to capture the name of an image file created with scrot. I can capture the filename like this: $ image=$(scrot -s -e 'echo $n') $ echo $image 2018-09-07-140419_185x76_scrot.png I need to do ...
2
votes
1answer
940 views

Setting the root PATH for su [duplicate]

When I am changing (on my debian box) to the root user with su, apparently the PATH is not correctly set. Some vital directories like usr/local/sbin are missing. In /etc/profile I have the following ...
1
vote
1answer
406 views

How to add file to /etc/sudoers.d/ from non-root user?

I'm trying to write a script for Centos 6.8 where the user will not be root. There is no admin on the premises, so the script needs to be added to the sudoers (by adding a file to /etc/sudoers.d) by ...
1
vote
1answer
65 views

Linux - why do the su and sudo binaries need to be set-UID root?

I am trying to find the correct reason for the stated question. My understanding is that: sudo needs to read the /etc/sudoers file which is only readable by root, which is why it needs to be set-UID ...
2
votes
3answers
6k views

su - user Vs sudo su - user

sudo su - will elevate any user(sudoer) with root privilege. su - anotheruser will switch to user environment of the target user, with target user privileges What does sudo su - username mean?
1
vote
3answers
279 views

Why isn't .bashrc read when switching user?

On RHEL7 I see a different behaviour with startup scripts when I su to a user with /bin/sh or /bin/bash as the shell, despite the fact that /bin/sh points to /bin/bash I've got the following scripts ...
2
votes
0answers
54 views

Inconsistent behaviour with udev and “su -c ”

I have a JACK server set up in my computer to take care of all the sound inputs and outputs. When I connect an external USB sound card (name: CODEC), I want it to be detected by udev, so I setup udev ...
0
votes
1answer
41 views

Why is there a different result when running as user1 and su - user1 -c “command”?

When running as user1 in the same directory (/home/user1/WWW) [user1@server1 WWW (master)]# touch c Creates the file c inside the directory. [root@server1 WWW (master) ACCEPTATIE SERVER]# su - ...
2
votes
1answer
287 views

How does Magisk on Android work as su without setuid and capabilities?

I've read in another answer that on Android the su binaries avoid needing to be setuid by using filesystem capabilities like cap_setuid. But then I tried to check this, and to my surprise, I found no ...
2
votes
2answers
1k views

How to run a command as apache

I want to edit my server files as a user in the apache group So, I need to chmod all files to 0775 as user apache. But, I am unable to su apache. I don't know the password for it, and entering empty ...
0
votes
0answers
63 views

Want to preserve bashrc and vimrc when switching to non-root users

I'm on a multi-user system. I have sudo b/c I'm responsible I guess. Sometimes, I want to switch to another user to help them do something, but I have a tricked-out bashrc/vimrc and I'd like to keep ...
2
votes
2answers
2k views

debian su - and su $PATH differences?

$ su - Password: # echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin # exit logout $ su Password: # echo $PATH /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games I have ...
0
votes
1answer
114 views

getting IP address of red hat users that connected using SU - [closed]

TL;DR: why on a single server the who -m command doesn't provides the output of IP address and the username that initiated the connection to the server the Question: I have several Linux servers with ...
1
vote
2answers
240 views

How to run command as a different user when there are no sudo or su commands

I have this quite unusual condition here. I have a old linux system that has no sudo or su commands. I do not have physical access to this computer so I cannot login as another user. Linux kernel is ...
1
vote
1answer
228 views

MacOS: su pkill -9 “process_name” = sorry

How to use pkill as su on a Mac? When I run su pkill -9 "RFBEventHelperd" in the terminal I get su: Sorry (but works as sudo). I am looking for a way to kill this process from inside a script that ...
3
votes
3answers
441 views

bash: executing su -c breaks $@

Bash version: GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu) This works fine: #!/bin/bash exec /usr/local/bin/python2.7 /app/add_container_host.py $@ But I need to run it as a certain ...
1
vote
1answer
81 views

`su -c` as another user doesn't work in a Rails repository

In a bash script that has plenty of commands run as another user, I've found a class of commands that don't seem to work. In a Rails repository as root: > su -c 'whoami' at at > su -c 'rake ...
0
votes
2answers
204 views

How do I su into another user if the user has no password assigned to it?

I have a user named lap that was set up during install of a service named lap. I have to be logged in as user lap to execute certain functions and to access some directories. I do not have the root ...
1
vote
0answers
34 views

Can `su` preserve resource limits?

I am under user t and then switch to t again via su t: $ ulimit -c -H; ulimit -c 1000 1000 $ su t Password: $ ulimit -c -H; ulimit -c unlimited 0 Is it possible to request su to preserve resource ...
-3
votes
1answer
59 views

When the user of a shell is `root`, does running `su` on another user name ask for password of the other user?

When the user of a shell isn't root, running su on another user name will ask for password of the other user. When the user of a shell is root, running su on another user name doesn't ask for ...
4
votes
0answers
983 views

Gain root access without using root's login shell

I bricked the login of my root user by removing zsh while it was still the default shell. Now as a result will login in fail, since on login will it try to use /bin/zsh(1), which is missing. Only one ...
0
votes
1answer
49 views

Why can't login be invoked as a sub-process and executed in any shell but the login shell?

From manpage of login The login program is used to establish a new session with the system. It is normally invoked automatically by responding to the login: prompt on the user's ...
0
votes
1answer
62 views

What are the differences between `su target-user` and `login target-user` ?

What are the differences between su target-user and login target-user ? The latter may need sudo. They both seem to me to create a login session for target-user. Thanks.
-1
votes
2answers
1k views

Why can't I `su postgres`?

I wonder why when I provide root's password, the following command reports failure? $ su postgres Password: su: Authentication failure Is it correct that su asks for the password of root, not of ...
2
votes
1answer
202 views

Does su always change ruid, euid and suid to the same user id?

Does su always change ruid, euid and suid to the same user id, or just some of them? I feel all of them, because the process which is executing su is always run with superuser privileges, and in ...
1
vote
5answers
6k views

ssh login as user and change to root, without sudo

I have the following task: the command has to be run as root on server remotely in bash script over ssh and the command output has to be fetched in variable. logging over ssh as root is disabled. ...
0
votes
1answer
49 views

su - user -c env not getting environmental variable without -l added

I'm having an issue at the moment that I don't understand what is going on as I am very new to Linux. There is a script that I am trying to run (which I won't post as I don't think I am allowed to) ...
0
votes
1answer
180 views

Alpine Linux - restrict su -l to wheel group

What's the best way to restrict su -l only to people who are in a specific group? I'm on Alpine Linux. I've already added linux-pam package but I'm not able to make it run. That's my current /etc/pam....
0
votes
1answer
51 views

Run command with specific arguments without password as root for all users [duplicate]

I want to be able to run fdisk -l as any user, without getting the whole fdisk: cannot open /dev/sda: Permission denied message. I don't see how fdisk -l can be used for malicious purposes. I have a ...