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

learn more… | top users | synonyms

33
votes
3answers
2k 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 ...
3
votes
1answer
44 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 ...
0
votes
1answer
21 views

Set root password AMI linux

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

Disabling su - <user1> alone

In my Team , we have a server which few people know the root password I can see they log into root and then use su - user1 to use from user1 login., I cannot change root password for some reasons , ...
1
vote
2answers
40 views

sudo / su to user in a specific group

I am looking to setup a generic user that has the ability to su/sudo to any user in a specific group. Either that or to any user that has a specific naming scheme. Is this possible on linux? I ...
0
votes
3answers
39 views

switch to sudo user with AND command doesnt work

I am trying to copy the ssh private key from one user to another user in single shot. sudo su && cp /home/sk/keys/master.pem /home/sg-user/keys/ This command works well, when i run them one ...
0
votes
0answers
17 views

su - with -s option and environment - why symbolic link doesn't work? [duplicate]

here's the trick: [root@aaa ~]# su - -s /bin/sh gerrit -c 'env' HOSTNAME=aaa JAVA_HOMEC=/opt/jdk/ SHELL=/bin/sh TERM=xterm-256color HISTSIZE=1000 JRE_HOME=/opt/jdk/jre/ USER=gerrit ...
0
votes
0answers
41 views

Use sudo as login

I've picked up the habit of using sudo and disallowing root logins. In cases, sudo is integrated with GUI configuration tools that require it. Are there any serious efforts to replace login and ...
2
votes
0answers
22 views

Bind a directory as me

Analogous for a regular user running a thin FTP server (where others can access the file system with his/her permissions), can a regular user (through fuse maybe) "mount" a directory for others to use ...
2
votes
2answers
257 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.
1
vote
3answers
93 views

Differences between sudo and su in inheriting environment

Why can the command run by sudo inherit the environment from the parent shell process, while the shell process after sudo su to the root user doesn't? t@ocean:/tmp$ export ME=tim t@ocean:/tmp$ sudo ...
1
vote
0answers
83 views

Decrypting with GPG after a “su - different user”

I have cron job running a script in the cron of "USER A" that encrypts many files in a loop using the gpg command below: gpg --batch --cipher-algo AES256 --passphrase "PASSWORDISHERE" -c FILENAME ...
0
votes
2answers
100 views

executing command as su

I am executing this command as su. I have made the connection with SSH (using sshNet), and then when I try to set the command su -, I get no response. I have the password and the command I would like ...
1
vote
1answer
81 views

Running some parts of a script as an unprivileged user with shell environment

I am creating an instance configuration script that sets up a machine. I am running the script via sudo i.e. sudo run.sh. Most of the steps require root access but some of the script's steps do no ...
2
votes
3answers
344 views

Why root does not source .bash_profile?

Everytime I try to login as root using su (not su -), it doesn't source .bash_profile in user1's home directory. Basically my /var/root directory doesn't have .bash_profile, so I put a copy of ...
0
votes
2answers
70 views

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

Good day 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 ...
1
vote
1answer
50 views

Can't switch to a specific system account with su

I can't switch to user jenkins on an OpenVZ container. There is still a jenkins process running, which was started by this user. I tried # su jenkins; it does not switch to the jenkins user. There is ...
1
vote
2answers
143 views

su -c command fails when sending db2 commands

I have a script I've setup to run a number of tasks, one of which is to set up a table in a DB and later remove it (for automated testing). The issue comes that on only a few of the users that I use ...
0
votes
2answers
94 views

Why doesn't `sudo su -l -c “java”` work even though `sudo su -l -c “echo $PATH”` displays the location of the java binary? [duplicate]

I have a server with Java binaries from a tarball on a custom location, and the following in /etc/bash.bashrc: export JAVA_HOME=/path/to/java/home export PATH=$JAVA_HOME/bin:$PATH When I run sudo ...
3
votes
3answers
159 views

SUID accidently removed from /bin/su file

It is a production server - CENTOS 6.1 Some user having root access in the past had logged on to the server and removed the SUID bit from the /bin/su file and then exited root. Now we are not able to ...
1
vote
2answers
138 views

Any special permission ssh remote command working on fifo file(aka named pipe)?

I need to redirect some strings to a fifo file with ssh remote command, but always got permission denied, the command I executed is: ssh rundeck@nagios1 sudo su - root -c 'printf ...
0
votes
2answers
99 views

provide password for script begin called inside another script [duplicate]

I have written a shell script which in turn calls another script, but the second one prompts for password. I want to supply the password and pass the prompt without user begin notified. Here is my ...
1
vote
1answer
94 views

su or sudo keeping/removing certain environment variables

I would like to be able to log in as another user and keep most, but not all of my environment. Specifically, I would like to set $HOME to the correct value for the new user, but keep probably ...
1
vote
1answer
65 views

How to switch user with pre-configured credentials in SSH Terminal after logging in as standard user

I was wondering how to execute a command file where: After logging in as a standard user, I want to switch user to "username" with password being "password", I can successfully execute the command.txt ...
0
votes
1answer
68 views

shell scripting and running after switching to other user

I have the following commands that I want to have them all in one shell file: su – s3 lizinfo.sh –b when the first linex executes, it prompts and the command prompt become like as below: ...
0
votes
2answers
60 views

Ubuntu CentOS RHEL cross bash script su support

I know that title was a little ambiguous. Allow me to explain our issue. We designed an installer script on Ubuntu since Debian based systems are our primary core, however, some of our cloud based ...
0
votes
2answers
50 views

Maintaining the Current Style of the Command Prompt After Using 'su?'

When I use the su command in OS X's Terminal — say, to quickly switch to an administrator account to mount a drive using diskutil — the style of the command prompt changes. ...
6
votes
1answer
246 views

When running 'su - username', pam_group doesn't add additional groups from /etc/security/group.conf but sshd login does?

I am having trouble determining why su doesn't behave as the PAM configuration would imply. In short, using su to become another user should load secondary groups according to PAM configuration, but ...
0
votes
1answer
49 views

Is there a way to see which user is logged into the system and has switched with “su”?

There are many person that may have access to the system and use a common user with more grants. How can I see which user is running a command? is there a way to use "ps" for that?
-1
votes
2answers
227 views

Is it possible to write a script that run su or sudo command without typing password? [duplicate]

Is it possible to write a script that run su or sudo command without typing password?. I googled and its said that su doesn't read password from buffer. So is there any solution?
3
votes
2answers
562 views

Is there a graphical sudo (kdesudo, gksudo, su-to-root, …) tool that works passwordless?

Apparently gksudo is not obeying /etc/sudoers, neither does kdesu. Therefore asking the other way around... Is there any su-to-root, gksudo, kdesudo, etc. alike tool, that supports starting gui ...
3
votes
1answer
46 views

limits.conf modification doesn't work

On a SLES 9 machine I added the line: vi /etc/security/limits.conf USERNAME hard cpu 70 but when I check it with "ulimit -a": SERVER:~ # su USERNAME USERNAME@SERVER:/root> ...
0
votes
1answer
52 views

/etc/sudoers file help in giving access to all command in UNIX

/etc/sudoers file help in giving access to all command in UNIX. I read it has rules specified like #root ALL=(ALL|ALL):ALL that specifies root accesses. My question is when we execute a command ...
0
votes
2answers
2k 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 ...
1
vote
1answer
34 views

How to propagate TSTP while running a program as a different user

I'm running a terminal application via "su" in this fashion: su -c "/path/to/app --args" username This is done from a root context, and 'username' is a less privileged user in the system. The ...
0
votes
1answer
619 views

Bash script class path issue with java

Content of /opt/scripts/jvm/jvm.script.sh #!/bin/bash JAVA_HOME='/java' PATH="$PATH:/$JAVA_HOME/bin" java -cp ./classes:./lib com.mystuff.bar.foo.myclass & Content of /etc/init.d/init.script.sh ...
1
vote
1answer
1k views

Ubuntu runuser command?

I am creating a bash script that requires to run commands as a specific user. As a result I am using the command: runuser I have tested this script and it works perfectly in Ubuntu Server 14.10. ...
2
votes
1answer
102 views

Problem with either su username -c “./script.sh” and sudo -u username bash -c “./script.sh” and Java classpath

I am seeing some strange behavior that has led me to wonder how the environment differs when running either of these 2 commands, versus using su username and then running the commands as the user one ...
1
vote
2answers
146 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
1answer
80 views

Accidentally deleted /bin/su

I was working in /bin on my Ubuntu system and ended up deleting su via a typing error while trying to do other editing. So now I have no way of swapping back and forth between users and root. I have ...
5
votes
2answers
99 views

Permissions depending on how you login: ssh/su/sudo

As user I have access to a remote linux machine where I can: sudo su - other_user Among other things, this allows me to add my own public key to authorized_keys for other_user, which effectively ...
3
votes
1answer
74 views

su - -c 'll' other_user results in error, how can I run this other user's alias?

In current bash session, I just want to change to another user for some bash command. The command is aliased to some script defined in another user's .bashrc or .profile. Am I able to make it ...
1
vote
1answer
769 views

su cannot execute bin/bash/****

I installed Kali Linux on a VM machine and I cannot change my user to root from the terminal using su. The command sudo works fine but when I try to su, it says "cannot execute bin/bash/****(my user ...
1
vote
0answers
63 views

Some commands does not work in su envirorment

I have logged in to CentOS 5 machine with normal user and then I used su command to login as root user. Now commands like ifconfig, useradd, userdel are not working on machine and it gives command not ...
2
votes
2answers
2k views

Unable to pass the password to su in a script

I am writing a build script. This script has to copy a file in the end. This file will be placed in another users home directory and it is also necessary that the file belongs to this second user. My ...
4
votes
3answers
1k views

What mechanism prevents any user from accessing any other user's files via root?

On a multi-user system, what protects against any user accessing any other users files via root? As context, the question is based on my understanding as follows: There are two commands related to ...
3
votes
3answers
68 views

Understanding a couple of points regarding root privileges

I just wanted to confirm my understanding of a couple of things related to root privileges. Is it correct that: The user name "administrator" is not a reserved name with implied privileges, it is ...
0
votes
1answer
280 views

Is it possible to set the users .gitconfig (for git config --global) dynamically?

I have the problem, that we login to the systems as our own users johndoe and then have to do a sudo su - root to be able to do administrative tasks. We have the system config files in a git ...
1
vote
3answers
1k views

Pass arguments to a command run by another user

I have a bash script that is supposed to take some arguments and then run in a different user: test.sh #!/bin/bash sudo su user2 <<'EOF' echo $1 EOF However it prints blank: $ ./test.sh ...
1
vote
2answers
638 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 ...