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

learn more… | top users | synonyms

0
votes
3answers
143 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 - ...
1
vote
1answer
65 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
3k 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: ...
1
vote
2answers
161 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 ...
2
votes
2answers
3k 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 ...
0
votes
0answers
98 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 ...
0
votes
1answer
97 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 ...
4
votes
1answer
140 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 ...
1
vote
0answers
440 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 ...
0
votes
1answer
287 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 ...
2
votes
2answers
3k 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 ...
1
vote
0answers
65 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 ...
2
votes
2answers
2k 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 ...
4
votes
2answers
257 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 ...
7
votes
4answers
1k views

sudo permission denied but su grants permission

this is the first occurrence where su was required for me. I read an article about changing the value in /sys/devices/virtual/backlight/acpi_video0/brightness to alter my laptop's screen brightness. ...
1
vote
3answers
497 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
191 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
151 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
466 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 ...
5
votes
2answers
673 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
1k 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
55 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.
6
votes
4answers
2k 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 ...
0
votes
2answers
4k views

Avoid asking password if `su -m user command` is used under `user`?

If I run the script containing su -m user service userservice start under root user, I do not need to enter the password. But when I run it under user user, it asks passwords all the time. That really ...
1
vote
3answers
103 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
97 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?
1
vote
2answers
133 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 ...
3
votes
2answers
1k 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 ...
1
vote
1answer
95 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 ...
2
votes
3answers
2k views

su: Permission denied despite correct password

In my new Gentoo installation, su doesn't work as my non-root user: After entering the correct password I get the message "su: Permission denied". What could be causing this? I have already tried ...
11
votes
4answers
9k views

Why doesn't “sudo su” in a shell script run the rest of the script as root?

A sample script can be as below: #!/bin/bash sudo su ls /root When using ./test.sh as the normal user, instead run ls as super user and exit, it switches to root; and when I logout, it executes ls ...
0
votes
3answers
86 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 ...
1
vote
1answer
2k 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 ...
82
votes
7answers
11k views

Which is the safest way to get root privileges: sudo, su or login?

I would like to have the root account in safety even if my unprivileged user is compromised. On Ubuntu you can only use sudo for "security reasons" by default. However I am not sure it is any safer ...
1
vote
1answer
91 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
0answers
100 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 ...
3
votes
1answer
2k 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 ...
1
vote
1answer
123 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 ...
1
vote
3answers
4k views

running multiple commands for su in bash

I would like to use su -c to run as root multiple commands altogether. I don't want to use an extra script for this. I tried the following su root -c "tcpdump -i wlan0 -s 1500 -w CCCCCC & " ...
4
votes
2answers
320 views

Two GUI applications as different users on the same screen

I am logged as user A. I want to run a GUI application as user B. User, not root. User B is local too, not remote, I only need different environment variables. I don't want to run the second X, I want ...
0
votes
1answer
407 views

Difference between sudo su - user and sudo -iu user [duplicate]

I was wondering if there were any difference (in environment ?) between doing sudo su - user and sudo -iu user From what I know: By using sudo su - user I open a new shell as user, and the ...
-1
votes
1answer
970 views

Where does sudo get the currently logged in username from?

When I tried to "sudo su" instead of "sudo su -" after having been logged in as root and su-ing to another user, it tries to sudo me as the new user, but via root... When I type env, it shows still ...
2
votes
3answers
2k views

Using sudo in openSUSE without actually changing to root user (i.e., like in Ubuntu)

I recently started trying openSUSE 12.3 after having used Ubuntu for a few years. I'm still getting used to openSUSE's treatment of su (and sudo) vs. Ubuntu's use of sudo. I've been reading the ...
2
votes
2answers
174 views

How to su to www on OpenBSD?

I have a PHP script that I wish to run under the www account. The account has nologin as shell and is used by Apache. When I run "su -l www -s /bin/ksh" as root, I get the following message: This ...
0
votes
3answers
710 views

What does sudo su work but su does not? [duplicate]

I have tried this on Fedora and on Ubuntu. kshitiz@kshitiz:~$su su: Authentication failure kshitiz@kshitiz:~$sudo su root@kshitiz:/home/kshitiz# I am entering the same password in both the cases. ...
2
votes
4answers
3k views

Should I use `sudo` or `su` in a startup script?

I have a personal program, that has a server/client design. The server daemon part of it, should be run as its own limited user, and the program was not designed to drop its root privileges (if ...
2
votes
1answer
348 views

Setting the root password vs. sudo -i

Should one always set a root password, or is sudo -i acceptable? Two problems is in reading other posts (maybe junk I realize): sudo -i eliminates the need for a password. Isn't that a problem for ...
2
votes
1answer
2k views

Can't use su or sudo on Arch Linux

Sudo returns this error: sudo: effective uid is not 0, is sudo installed setuid root? And su - returns this: su: Authentication failure The user I'm using is a member of the following groups: ...
7
votes
1answer
826 views

How to stop users from Switching to Root user

I have disabled the root user login from Sshd.conf file so now no one can login using root user even if they know the password SOMEHOW. Now I have 3 users in server ROOT,EMERG and ORACLE. I want to ...
0
votes
1answer
259 views

SSH minimal rights user - su only [duplicate]

Possible Duplicate: Creating a UNIX account which only executes one command I am trying to setup a user account that only has as minimal rights as possible. The user should be able to log ...