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

learn more… | top users | synonyms

105
votes
6answers
37k views

Where did the “wheel” group get its name?

The wheel group on *nix computers typically refers to the group with some sort of root-like access. I've heard that on some *nixes it's the group of users with the right to run su, but on Linux that ...
-3
votes
2answers
46 views

How are setuid, suid, sudo, and su all related? [duplicate]

I have a feeling the setuid bit, the nosuid mount option, sudo, and su are all related given their names. But how do they relate to one another? Are some of them used in conjunction? If they are not, ...
1
vote
2answers
176 views

Run script on non-full bash-login invoked as “sh”

I'm currently trying to modify my terminal to have the prompt displayed in a different colour than the whole rest of the shell, and I would like to make it white for normal users and red for root. I ...
4
votes
3answers
25k views

Cannot connect to X server :0.0 as superuser

When I am online, I get following error and the tool does not start: [root@dhcppc9 lin64]# ./ise No protocol specified _pn: cannot connect to X server :0.0 But everything is OK when I am not a ...
3
votes
1answer
51 views

root cannot connect to symlinked socket of other user

I use oh-my-zsh's ssh-agent plugin to have a static symlink to my current SSH_AUTH_SOCK created. When connecting through SSH with agent forwarding enabled the file /tmp/ssh-agent-$USER-screen is ...
8
votes
2answers
8k views

How to run a GUI program as a different user (Debian)?

Using a terminal, I can change the running user with su and sudo — but how can I do that by clicking on an icon/shortcut on the desktop/start menu? If I have to be root to execute I will be asked ...
0
votes
1answer
19 views

X Forwarding over SSH when switching users [duplicate]

How do I forward X when switching users? I can ssh -X username@server.example.com and open GUIs just fine. However, then when I sudo su to root, the X11 forwarding seems to stop because the windows ...
1
vote
1answer
13 views

How (or is it possible) the Linux desktop X-Server from Terminal under an SU otherusername

I have a simple scenario to demonstrate the use-case for this question Login to Linux as currentuser start bash terminal xauth list $DISPLAY mint/unix:0 MIT-MAGIC-COOKIE-1 ...
5
votes
3answers
5k views

how to pass environment variable to sudo su

I basically need to do this: DUMMY=dummy sudo su - ec2-user -c 'echo $DUMMY' This doesnt work. How can I pass the env variable $DUMMY to su? -p doesnt work with -l.
0
votes
1answer
72 views

What's different between “su - username” then command and “sudo -u username command”

I have a problem about unixodbc. It show the error message about Can't open lib .... So, I use the ldd command to check. If I use su - username,the result like below: [root@ostest ~]# su - mysql ...
2
votes
1answer
66 views

When can a user do `sudo su` but not `sudo su -`?

The following happened to me: $ sudo su - superman Sorry, user clarkkent is not allowed to execute '/bin/su - superman' as root in krypton101. However the following worked fine: $ sudo su ...
12
votes
3answers
6k views

Difference between sudo -i and sudo su [duplicate]

I was wondering what the difference is between sudo -i and sudo su?
46
votes
4answers
3k views

Is there ever a good reason to run sudo su?

To launch a root shell on machines where the root account is disabled, you can run one of: sudo -i : run an interactive login shell (reads /root/.bashrc and /root/.profile) sudo -s : run a non-login ...
0
votes
0answers
73 views

sudo and su hang indefinitely… stumped

I am trying to run su or sudo on my CentOS 6.6 machine. Every time I try to execute either command, I get prompted for a password. After entering the password, the command simply hangs. I can ctrl+c ...
2
votes
2answers
10k views

can't ssh into remote host with root, password incorrect

I have a remote host, previously I can ssh into it with root and password ssh root@remote_host or I ssh into it first using a regular user account ssh esolve@remote_host and then su root and ...
1
vote
0answers
24 views

What command should I use to explicitly set list of groups and execute a command?

To execute a command as other uid, one uses su. The list of supplementary groups is not specified on command line, but instead read from configuration files (/etc/passwd, /etc/group), etc. Which tool ...
22
votes
3answers
31k views

“su” with error “X11 connection rejected because of wrong authentication”

As root, I'm connecting to a remote host to execute a command. Only "standarduser" has the appropriate id-file and correct .ssh/config, so I'm switching the user first: su standarduser -c 'ssh -x ...
0
votes
2answers
96 views

Fedora 23 password only showing 5 characters. Issues using su command

Today I installed Fedora 23, and once I finished I had no problems the SU command. I rebooted my VM and logged in, and it wont let me use the SU command. When I enter it, it asks for my password. So I ...
1
vote
1answer
82 views

want to su without password inside shell script

I have written a script which will run a script for a backup before: # cat backup-before-shutdown #Scritp to take backup before shutdown #Author Ashish Karpe echo "Taking backup to s3" su ubuntu ...
1
vote
3answers
1k views

How can I sudo su and change directory just after?

I would like to create an alias that does something like this: alias userYYY='sudo su userYYY; cd /a/path/that/only/userYYY/has/access' So then from my command line, I am logged in with a sudoer ...
1
vote
0answers
101 views

Slow script execution

I have a strange problem... My script: #!/bin/bash SECONDS=0 lock_file=/tmp/$0.lock [ -e $lock_file ] && exit touch $lock_file echo "<<<db2_hadr_check>>>" instances=( ...
1
vote
3answers
204 views

Fedora: How can I add myself back to sudoers file?

I've accidentally removed myself from sudoers file by doing usermod -G user group without -a, and now I am not in the sudoers group. I've tried doing su - and entering root's password but it says su: ...
1
vote
0answers
32 views

Linux/CentOS - can't su after changing ownership

I mistakenly changed ownership of all files on a CentOS system from root to my login account. I can login but if I su I get: su: cannot set groups: Operation not permitted I don't need the system ...
1
vote
2answers
2k views

Problem executing command as a different user with sudo -u

I have the following problem: When I'm trying to execute ls as user abc with the following command I get an error: xyz@host:~/temp$ sudo -u abc ls [sudo] password for xyz: Sorry, user xyz is not ...
37
votes
2answers
16k views

su vs sudo -s vs sudo -i vs sudo bash

What is the difference between the following commands: su sudo -s sudo -i sudo bash I know for su I need to know the root password, and for sudo I have to be in the sudoers file, but once executed ...
1
vote
2answers
72 views

How do I fix my /etc/sudoers file to recognise me?

Currently, I am receiving the following terminal error: sudo: parse error in /etc/sudoers near line 10 sudo: no valid sudoers sources found, quitting sudo: unable to initialize policy plugin I have ...
9
votes
7answers
9k views

How do I suppress dd output?

I have a bash script that creates some file using dd. The problem is dd throws a great amount of output that is going to mess with the output of my script. Searching around I've found a solution: dd ...
1
vote
1answer
52 views

Set root password AMI linux

I need to set a password for root on EC2 AMI Linux. I have tried with passwd root but if I log in with ec2-user and run sudo su, I get a root bash without asking for a password.
1
vote
1answer
115 views

Bash script with (X)dialog asking for root password (kdesu substitute)

I'm using (X)dialog for a script that a normal runs, but it needs root privileges for some commands. The script runs from a .desktop file, thus the user sees no terminal. For example here #!/bin/bash ...
-1
votes
2answers
189 views

When in debian 8.1 why is the super user run with su not sudo? [closed]

I am curious why the super user command su is run and not super user do (sudo).
1
vote
1answer
123 views

Valid root/user passwords not working on EC2

There is an authentication failure when I'm trying to enter password for any of my accounts after an update using yum. My authentication got broken, while everything else works. The updates were ...
0
votes
0answers
31 views

Why use use su -c to start background processes?

After reading Link im under the impression that using su -c with & would be redundant. My reasoning is that any process started with su -c will be started in a new shell but it will not be killed ...
1
vote
1answer
51 views

Differences between `su` and `su-to-root`?

There are other questions on this forums about the usage of su, su -, su root... etc. But I have found none about the su-to-root command, and I would like to understand the basics of its usage. ...
1
vote
1answer
33 views

Make superuser act like some other user in certain directory tree

I have the following problem: My home directory lies on the network and is mounted locally on home/<my username>. I can access it with my normal user account <my username>, but as root, I ...
5
votes
2answers
18k views

How can I run as another user?

This is the bash code that should be runned. So first it substitutes the user to openproject and than runs all the code su openproject -c "bash -l" cd ~/openproject git checkout Gemfile.lock git ...
0
votes
1answer
65 views

What's wrong with exit command on my terminal?

I'm using Linux Mint 17.2 Cinnamon, and I'm a beginner, just switched over from Win10. Somehow, the exit command isn't working, could somebody help me out?
0
votes
2answers
407 views

`su` command: Permission denied

When I type into bash the following command su -s /bin/bash as root, then no error occurs. When I type su -s /bin/bash -m [MyUserName], then I get the error: Permission denied. As far as I could ...
0
votes
1answer
67 views

Is it possible to execute a command as another user without sudo su'ing to that user?

I do a lot of administration in CentOS6 for several teams. One of the more frequent things I do is sync down and package code as the team account, before deploying it out under my own account. Is ...
1
vote
4answers
108 views

What's the difference between sudo su vs just su?

I see a lot of posts out there that say you type in sudo su to get an interactive prompt with root privileges, and I see equally many posts debating the pros and cons over sudo -i vs sudo su. Here ...
2
votes
0answers
28 views

Slackware su man pages does not mention /etc/suauth, what reason?

I've been reading the man pages before I start restricting su access to certain users (I'd like to not rely on sudo if possible). There is no /etc/suauth file so I was going to create my own and ...
0
votes
1answer
74 views

ssh master - execute su remotely

I have a server S that I need to connect to. I'm connecting to S as user asdf with control master and after that I perform some stuff: ssh -N -f -M -o ControlPath=$SSHSOCKET ${USER}@${IP} -p ${PORT} ...
2
votes
0answers
130 views

Difference between 'xhost + ' and 'xhost +SI:localuser:AnotherUser'

If I do xhost + >access control disabled, clients can connect from any host su AnotherUser -c xterm an xterm popups, but if I do xhost +SI:localuser:AnotherUser >localuser:AnotherUser being ...
1
vote
2answers
232 views

run command with sudo su in script and redirect stdin and stdout

I need to run command as another user and write to its stdin and read from its stdout. I can run command as another user only via opening new shell: sudo su anotheruser but with new opened shell i ...
0
votes
2answers
4k views

Unable to su into an account: could not open session

in my Linux machine - red-hat I successfully to login to different users as the following su - userC [machine@Linux ~]$ pwd [machine@Linux ~]$ /Users/userC but only in one user I get the ...
2
votes
3answers
5k views

Allow paswordless user to change to another passwordless user

I have two users dev and tomcat neither of them have a password. How can I allow dev 1 do su - tomcat without having him having to enter any credentials? 1 connects with ssh keyfile
3
votes
2answers
96 views

Why does man page completion fail after su?

I have a default Debian 8.1 installation. I do su man apt<TAB> but get nothing. I do see the manual when I write man apt-get in both modes: as user mas and as root. However, tab ...
87
votes
2answers
19k views

Why do we use su - and not just su?

I don't understand why su - is preferred over su to login as root.
16
votes
1answer
2k views

What's the difference between sudo su - and sudo su --

When I am working on our RHEL machines, I use sudo su - to switch to being root. One day, a typo meant I typed sudo su -- instead - it seems to me that everything was the same as with a single hyphen, ...
3
votes
1answer
343 views

Possible to pipe command using su via ssh

I'm trying to write a python script to remotely update the login passwords for a set of account I administer - I can already successfully use python to pipe remote commands via the stdin of an ssh ...
15
votes
3answers
43k views

su options - running command as another user

I was wondering how to run a command as another user from a script. I have the script's owner set as root. I also have the following command being run within the script to run the command as the ...