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

learn more… | top users | synonyms

2
votes
1answer
45 views

root login silently fails

After some months of not touching it I wanted to login to one of our virtual servers to update OpenSSL, because of the heartbleed thing. The server is running Debian 7, sudo is not installed. I ...
3
votes
2answers
81 views

Passing arguments to su-provided shell

man su says: You can use the -- argument to separate su options from the arguments supplied to the shell. man bash says: -- A -- signals the end of options and disables further option ...
2
votes
2answers
76 views

How do I emulate su's behavior with sudo?

I'm trying to make sudo ask for target password, except when run by root. Here's what I do: Defaults:!root targetpw This way it asks for my password, and if I make it like this: Defaults:yuri ...
8
votes
2answers
113 views

How do I elevate privileges in the middle of pipeline?

My guess was as follows: echo "Generating some text" | su - -c cat >/output/file But su says: su: must be run from a terminal What would you do?
1
vote
2answers
34 views

How to log out of su and another user

So when I am logged in as a standard user in an ssh session and then su to root, how can I log out of both accounts with a single command? Rather than: root@host:/exit user@host:/exit something ...
2
votes
1answer
37 views

Impossible to execute a command by using su for another (system) user

I've created my user like this: sudo adduser --disabled-password --system --home /var/lib/deluge --gecos "Deluge server" --group deluge The content of /etc/passwd: deluge:x:110:114:Deluge ...
1
vote
1answer
15 views

Changing the PATH variable for a process running as a user on Linux

I have a server application which I start using an init.d script and run as a user: su $USER -c "${PLAY} start ${APPLICATION_PATH} --%prod-test >/dev/null" The application needs ffmpeg, which is ...
0
votes
3answers
57 views

Can sudo to user but 'run command as' is denied?

I was wondering how to run a command as another user from a script without password. sudo -l return: (root) NOPASSWD: /bin/su - someuser There is no problem to sudo as someuser. Command sudo su - ...
8
votes
2answers
486 views

I Can't login as root with su command, but I can with SSH

How is it possible that I cannot log in as root by su root or su (I get incorrect password error), but I can log in by ssh root@localhost or ssh root@my_local_IP with the same password? I'm using ...
1
vote
1answer
39 views

super user group or user?

I am using the following command in Oracle Exadata: sudo su - odiadmin As sudo prompts for my own password, I am wondering if I upgrade myself to super user or do I switch to superuser ...
2
votes
3answers
256 views

How to login as root from Bash and do stuff

This is my simple bash: cat test.sh #!/bin/bash echo "hello" su - root -c /path/to/script.sh <<EOF password EOF whoami echo "good bye" But I get this error: ...
0
votes
0answers
45 views

running a command as a less privileged user: `sudo -u` vs `su` being run as root

in an startup-script that is typically being run as user root, i would like to start a program (actually, a server) as a less-privileged user. the script originally used su -s /bin/sh -c ...
2
votes
2answers
293 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 ...
1
vote
1answer
73 views

Why would we su without -? [duplicate]

When we do su John I switch as user John. When we do su - John I switch as user John having user John's environment. As far as I can see the first option is useless. What is the use of switching to ...
1
vote
1answer
95 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 ...
1
vote
3answers
137 views

Why is the 'sudo' password different than the 'su root' password

On my personal machine, I often type sudo in front of certain commands in order to accomplish administrative tasks. I had hoped to avoid doing this throughout the day, by typing su root and providing ...
0
votes
1answer
55 views

Why can't I su when if I am in the wheel group in OpenBSD?

Using a OpenBSD 5.4 (GENERIC) #37: Tue Jul 30 15:24:05 MDT 2013 I created a new user named "bela" and added it to the wheel group: # adduser Use option ``-silent'' if you don't want to see all ...
1
vote
2answers
75 views

Script to su -c into a screen is not working as intended

I'm working on a script that will allow me to load up a screen from a user via sudo and su -c. However, when I use it, it will just show the shell of the user: sudo su -c "script /dev/null; screen -r ...
3
votes
1answer
119 views

Running GUI application as another (non-root) user

Let's say I have 2 user accounts user1 and user2. When I login as user1, and then switch to user2 using su, I can execute command-line programs, but GUI programs fail. Example: user1@laptop:~$ su - ...
1
vote
0answers
213 views

Automate `pbrun su` via plink

I am trying to automate an sFTP process for our project. When I login with PuTTY and manually type the command pbrun su - user1, root access is given to user1 and I am able to do the sFTP process. I ...
4
votes
1answer
104 views

Is there any point in using `sudo` when you are the sole user of your machine?

I'd like to know if there is any reason why I should use sudo instead of su, taking into account that I am the owner and sole user of my machine (and hence have root access whenever I want). Also, in ...
0
votes
1answer
89 views

How to get pid of su --session-command file thats ran on there [closed]

This line ran in a script su --session-command="$javaCommandLine & >>$serviceLogFile 2>&1 & echo \$! >$pidFile" $serviceUser || return 1 pid="$(<$pidFile)" echo $pid The ...
3
votes
1answer
648 views

Command : must be run from a terminal

I have a shared hosting account, I logged using ssh. when I type for example su I had this output : su: must be run from a terminal Is this error relative to the fact that I don't have sufficient ...
2
votes
2answers
913 views

su - user doesn't work for users without a password

I've created a user on CentOS with useradd -M username. Now, I want to become that user just like su - username. It asks me for a password for that user but I didn't set a password for that user. As ...
7
votes
3answers
252 views

Difference between sudo -i and sudo su [duplicate]

I was wondering what the difference is between sudo -i and sudo su?
1
vote
0answers
52 views

can't access account with empty password

I used the passwd command to remove the password for my account. Now, when I try to use su to log in to my account, it won't let me enter an empty password. So now, I can't access my account. Any ...
4
votes
2answers
212 views

How do I execute a command on login for a system user with no home folder and no personal .bashrc file?

I set these users' home folders through the /etc/passwd file, but when they log in I would like them to activate a python virtualenv. If they had a personal .bashrc file, I'd just include the activate ...
1
vote
2answers
860 views

How can i run a part of a script as a different user?

#!/bin/ksh (some code) Log=~/my.log chown USER1 filename su - USER1 -c " date | tee -a ${Log} 2>&1; cd /blah/blah if [ SOMECONDITION ] then sh ./somescript.ksh > logfile fi exit" | tee -a ...
1
vote
3answers
247 views

How to gain root privileges for specific user if we have root password? [closed]

Can someone suggest how can I change process privileges in Linux to root ? Assume, I have a normal process running under some user-consider me. Now my script should create some users using 'useradd' ...
1
vote
2answers
125 views

Can't run su after changing permissions to su file

I am running Linux Slackware 14.0. I wanted to allow to do su only to the members of wheel group, so I modified the permissions of /bin/su and /usr/bin/sudo files to this: bash-4.2# ls -la /bin/su ...
5
votes
1answer
112 views

How to allow to run su instantly after I added the user to the appropriate group

I have the su executable with the following permissions: bash-4.2# ls -la /bin/su -rws--s--- 1 root wheel 59930 Sep 14 2012 ./su When I am logged in as a user, not in the wheel group and try to ...
0
votes
3answers
268 views

Create a file as a different user and group

I have a bash script with downloads some files, and then needs to set the owner to apache, and the group to a particular user group (that apache is not a member of). Is there a way to create those ...
2
votes
2answers
290 views

how to ssh -Y and then su - <another user> and still forward X applications to your local machine

it is easy enough to 'fetch' (ie draw locally) a remotely running linux application: If I ssh -Y to the remote machine and run an application, that application will surely enough pop up in my local ...
1
vote
1answer
380 views

How does this su -c “…” command seem to pass two commands instead of one?

I am trying to understand the script below and I am confused about the su line. I understand the postgres command line arguments. when I do man su the manual says -c, --command=COMMAND ...
0
votes
1answer
52 views

I want to create a script so that I don't have to type su and password every time [closed]

I want to create a script so that I don't have to type su and the password for logging into root every time.
5
votes
4answers
774 views

Why can't we execute a list of commands as different user without sudo?

This question has been asked in a different way in other forums. But there has not been a decent explanation why you can't do the below in bash. #!/bin/bash command1 SWITCH_USER_TO rag command2 ...
1
vote
3answers
92 views

Is there any way to disable shutdowning remote machine?

I sometimes mistakenly shutdown the remote machine by using sudo init 0, so I wrote something like in one of my rc files: alias sudo='sudo ' if [ $SSH_CLIENT ]; then alias init 'echo Never use init ...
1
vote
3answers
91 views

Confused on user and su in linux

How could I run a script as a specific user (non-root)? As this? sudo su - john /usr/share/script.pl for user john?
2
votes
2answers
209 views

How to source correct startup scripts on interactive, non-login shell

I'm trying to set up a sane/usable environment in a barebones OpenSolaris-derivative (OmniOS, a distribution of Illumos/OpenIndiana). I have all the plumbing code I need in .profile, .inputrc, and ...
1
vote
2answers
106 views

Staggering the authentication delay on failed `su` or `sudo` [duplicate]

I'm about to start my new job as a sysadmin and I've been thinking about implementing a cooldown feature on su or sudo. The cooldown prevents the user from using these commands for a few seconds after ...
0
votes
0answers
94 views

CentOS custom livecd using su throws: “Error setting value: Failed to contact configuration server…”

I am building my own custom CentOS Live CD with tools and settings I need. But if I want to root myself using "su" I always get this error message: Error setting value: Failed to contact ...
2
votes
2answers
328 views

Setting umask for su root

In my user account I set the umask to be 022 with my .bashrc, but I want root to use a umask of 077 no matter how I become root (e.g., logging in directly as root on a tty or using sudo or su). If I ...
2
votes
2answers
944 views

How can I mimic `sudo su - user` in a script?

I need to deploy my app to server called lovelyplace by a Fabric script. Unfortunately, the server's setup is horrible, but I can do nothing about it - I have to live with it. There is one non-root ...
1
vote
1answer
73 views

ssh key authentication not working from network/if-up.d/ scripts

I have two nearly identical scripts in network/if-up that need to access SSH keys. Permissions on SSH private keys are 600, so how can my scripts access these keys? I would prefer to keep the SSH ...
0
votes
3answers
80 views

Is there a way to switch to “su -” after switching users through “su”?

Maybe the title wasn't worded quite clear. But basically what I want to be able to do is to switch to having used "su -" instead of the traditional hyphenless "su" after already using "su" to switch ...
0
votes
1answer
773 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
1answer
66 views

su command with -p or -m flags

What is the difference between the following su commands? su -m su -p I know that both flags are used to preserve the current environment but I don’t know the differences if there are any.
2
votes
1answer
1k views

Stop su from asking for a password

I am trying to run the following command as deploy from Java (the JVM is running as the user tomcat): sudo -u deploy /path/to/my/bash/script.sh PARAM1 PARAM2 My sudoers file has the following in ...
2
votes
0answers
86 views

Understanding getlogin spoofing

My question is in three (or so) related parts: 1) My understanding is that getlogin() will effectively return the auid associated with the process and so isn't actually changable by the user. Is that ...
1
vote
1answer
102 views

New Terminal not works when we use su root

When I use su root and then use gnome-terminal I get warning ** (gnome-terminal:2677): WARNING **: Failed to connect to the session manager: None of the authentication protocols specified ...