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
0answers
2 views

vnc on alternate account fails

I run su -l work -c "vncserver :3 -geometry 1200x900 -name Work" to connect via vnc to my work account from my private account on the same machine. When running vncclient, it starts with just a black ...
1
vote
3answers
35 views

“su doesn’t record the commands executed as root”

I am currently reading book Unix and Linux system administration - Evi Nemeth. On page 70 under the topic "su: substitute user identity" there is a statement that says "su doesn’t record the commands ...
4
votes
3answers
224 views

Run script with arguments as user

I am trying to make sure when a script is run it is run as a specific user without having to su to that user before the script is run. Also the script is run with a couple of flags for example ./...
0
votes
0answers
14 views

Question about su and environment variable [duplicate]

From this question: How can I preserve an environment variable across su -? and from man I know that su - <other users> will: clears all environment variables except for TERM initializes the ...
-1
votes
0answers
38 views

su command not working Red Hat

I'm not able to make su when I'm already logged in. But when I can successfully ssh with this account. The error obtained is su: Authentication failure This does not depend on a specific account....
0
votes
1answer
61 views

Can't seem to use “su” in Arch Linux

I installed Arch Linux through the Zen installer, simply because I felt lazy. During the installation, the setup wizard asked me for a root password, and I never entered one, thinking it would use my ...
0
votes
0answers
26 views

Switch back to root after switching using SU

I connect to my Ubuntu EC2 instance over SSH and authenticate using a private key. I am in the process of installing Cowrie on my Ubuntu instance and as per the instructions here: https://cowrie....
0
votes
1answer
49 views

Why doesn't GNU `su` respect end of options?

When I run user@hostname:~$ su -- root -z I get bash: -z: invalid option Usage: bash [GNU long option] [option] ... ... The above is the behavior I expect. When I run user@hostname:~$ su -l -- ...
0
votes
0answers
108 views

Weird behavior of su command

Everytime I run su command on this box, I constantly see the weird messages below. Switching user do eventually continue, but why are these messages showing? <Server>:~ # su - -bash: eval: line ...
0
votes
0answers
25 views

How to switch user in the server by su without password through shell script?

I am using cygwin to run my expect command for login into server. Once login i have to switch the user by su command writing password in the shell script which does not prompt for password and ...
0
votes
1answer
16 views

Why does sudo xhost throw an error on openSUSE, but su -c xhost does not?

Here are some things that work: xhost su -c xhost su -c su `logname` -c xhost Here are some things that do not work: sudo xhost sudo su `logname` -c xhost sudo runuser -l `logname` -c xhost sudo -u ...
1
vote
0answers
36 views

Running su inside mount namespace

I am testing mount namespace using the following steps: # unshare --mount # mount --bind rootfs/ ns_dir/ # cd ns_dir/ # pivot_root . . # cd / My rootfs has sub-folders /lib, /bin, /etc. I have put ...
1
vote
2answers
36 views

ssh on remote host but switch user on local host running as root

I have a script running as a root. It ssh to remote host and run a script as user gol. I have added ssh keys for the user(gol) to remote host. But since the script is run as a root it still prompts ...
0
votes
2answers
65 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
162 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
32 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
63 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
58 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 ...
21
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
18 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
70 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
53 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
167 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
29 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
323 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
155 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
70 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
335 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
19 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
746 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
102 views

Question about login logs using “sudo su - username”?

While doing my Linux training I found this curiosity: If I do "sudo su - username" and log into that username account, it doesn't count as login when I do "finger username" Take this image where "...
0
votes
2answers
653 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
726 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
493 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
110 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 ...
3
votes
1answer
1k 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
520 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
79 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
7k 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
451 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
56 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
50 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
340 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
2k 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
77 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 ...
5
votes
2answers
3k 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
115 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
299 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
268 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 ...