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

learn more… | top users | synonyms

0
votes
0answers
143 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
6k 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
87 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 ...
6
votes
2answers
7k 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 ...
5
votes
3answers
2k 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
133 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
292 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
2answers
968 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
581 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
157 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
360 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
2k 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 ...
3
votes
2answers
5k 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
1k 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
70 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
285 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
4k 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
863 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
246 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
159 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
604 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
1k 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
2k 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
57 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 ...
1
vote
3answers
106 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
101 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
353 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
154 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
2k 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
3k 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
106 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
92 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
3k 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
108 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.
3
votes
1answer
3k 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
108 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
134 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 ...
0
votes
1answer
534 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 ...
4
votes
2answers
386 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 ...
-1
votes
1answer
1k 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 ...
12
votes
4answers
11k 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 ...
2
votes
2answers
201 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
847 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
1answer
383 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 ...
4
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
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
1k 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 ...
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 ...