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

learn more… | top users | synonyms

0
votes
2answers
18 views

Locked out of SSH on LAMP server but have SFTP access

I made a mistake in /etc/sshd_config so have locked myself out of my remotely hosted server running Centos 6. It's running Apache and I have FTP access to /var/www and I know the root password. To ...
5
votes
1answer
413 views

What does su - `whoami` command do?

I am running a script in my project and I see this command su - `whoami` I am having a few basic questions: What does this command do ? What is the significance of `` quotes outside the whoami ...
25
votes
6answers
14k views

What is the need for `fakeroot` command in linux

Why do we need fakeroot command at all? Can't we simply use the sudo or su commands? The man page says: fakeroot - run a command in an environment faking root privileges for file manipulation ...
0
votes
4answers
7k views

Is there a difference between sudo su - root and sudo -u root -H /bin/bash?

Like title says, is there a difference between these two commands : sudo su - root sudo -u root -H /bin/bash I'm using GNU/Linux, if that makes a difference.
3
votes
1answer
29 views

Difference between sudo -s and sudo su -

It might be a duplicate and I'm pretty sure I already show an answer to that somewhere, but I wondered what are the difference in term of right and variable and other stuff between sudo -s and sudo su ...
2
votes
1answer
29 views

What do I need in my script to be able to change ownership of a directory structure that belongs to root to the current user running the bash script?

My bash script has the following section: su root -c chown -R smithb:other /export/home/smithb/workspace/rootownsit/ exit The directory rootownsit and its two sub directories were created and is ...
4
votes
2answers
20 views

Use non-root user configuration for root account

When I work with the terminal and use su or sudo to execute a command with the root user's permissions, is it possible to apply the configuration of my "non-root user" (from which I am invoking su or ...
2
votes
1answer
58 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 ...
2
votes
2answers
314 views

Sudo Su automated login

I want to automate the login process with sudo su. I have seen lot of questions on these, but none of them are working for me. Automate login with sudo and su Here's my what I tried so far echo ...
3
votes
1answer
36 views

Switching users without the - symbol

I had to switch to a different user earlier for something that I was working on. I have originally done: su support While I was successfully able to switch to support, I found I was unable to make ...
9
votes
3answers
5k views

.bash_profile not sourced when running su

I have a user, say user1, which has modifications to its .bash_profile, one of them changing the PATH, e.g.: export PATH=/some/place:$PATH. This change works fine if I log on as user1 or do a su - ...
2
votes
1answer
46 views

Does root not require a password to log in as a user?

Does root not require a password to log in as a user even though a password has been set for that user? When I am logged in as "root", su user logs me in as "user". There is no prompt for a password. ...
3
votes
2answers
364 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 - ...
0
votes
2answers
70 views

Error when running X11 application as root

I get this wierd error when I run applications as root. **(gedit:630): WARNING **: could not open X display No protocol specified Unable to init server (gedit:630): Gtk-WARNING **: Cannot open ...
2
votes
1answer
58 views

su not asking for password

My su does not ask for password. When I run su it simply logs me in to root. I tried su - root then it asks for password. Now, because of this kdesu runs applications with root rights without ...
1
vote
2answers
37 views

Problem executing command as differetn 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 ...
2
votes
2answers
49 views

Making su ask for password multiple times

Is there some way to make su ask for the password again in case of a wrong password (just as sudo does)? Initially I thought of this: while ! su -c foo; do read -n 1 -p "Retry(y/n)?" ch if [[ ...
1
vote
1answer
25 views

How do I switch user without any references to the old one?

A while back, when playing with unprivileged LXC, I discovered that the command to create a container failed if I used su to switch to the user, but it worked if I used ssh user@localhost to login. ...
3
votes
1answer
470 views

Why can I only use apt-get when I use “su”?

Not sure what info you need here, if any. Just let me know. I have a proxy that bypasses the corporate net set in my profile file for both su and normal user. When I do a sudo or regular apt-get ...
3
votes
1answer
993 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
3answers
139 views

Can sudo replace su?

There is much duplication of functionality on Linux-based systems, for example these do the same thing: sudo --login --user <user> sudo su - <user> The sudo-only approach looks more ...
7
votes
3answers
472 views

Difference between sudo -i and sudo su [duplicate]

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

can you only input the password once and then execute the su command without entering a password? [duplicate]

I am copying files from a remote server to my local server. Here is the code that does this: sshpass -p "password" ssh -q username@$192.168.162.156 "mkdir -p /temp ; ...
0
votes
1answer
93 views

How do you keep the password hidden when invoked during the su command?

This is the first time it has happened to me where I am using the su command and it actually displays the password on the terminal and doesn't stay hidden. Here is my code snippet: sshpass -p ...
1
vote
1answer
136 views

Switch users with sudo or su in a shell script

I inherited this. Long story short I have an XML file that is calling a shell to run some commands. Everything I have tried has failed at the second su in the script. Here are some of the failure ...
73
votes
6answers
21k 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 ...
2
votes
1answer
88 views

How to create an executable bash script for these commands?

I wish to create an executable bash script that will run the following commands as root, that is, using sudo su iptables-save | awk '/^[*]/ { print $1 } /^:[A-Z]+ [^-]/ { print ...
1
vote
3answers
72 views

Wrong Permission to /etc folder [duplicate]

I have given the wrong permission to the /etc folder chmod -R 777 /etc When I want to login as root it gives me an error and the following output. How can I correct the permissions? ...
1
vote
2answers
2k 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
97 views

How to return from root log-in to my user log-in?

I'm using SuSE Linux Enterprise and I know that there is a command su root for changing to root log-in. But what about the other way around? If I prefer to return to my user account, how to do it? ...
4
votes
3answers
936 views

`$XAUTHORITY` appears from 'nowhere' on su+tmux

When I switched from su+bash to su+tmux+zsh I noticed that I get $XAUTHORITY variable defined as /root/.xauthXXXXXX where XXXXXX are 6 random alphanumeric characters. With previous configuration X ...
1
vote
1answer
45 views

su to another user using ssh keys?

Assuming that user_A and user_B set up and exchange public ssh keys with each other, is it possible for user_A to su into user_B on the same machine?
4
votes
3answers
949 views

Automate login with sudo and su

I know the security risks, but I am performing this experiment/exercise on an old, seldom used *nix machine I have laying around the house. So doing this exercise will not bring any security risk to ...
0
votes
0answers
27 views

Help Parsing `su` Command … What Does the Hyphen Do? [duplicate]

In the command su - username, what is the function of the hyphen? It seems to work all the same without the hyphen.
2
votes
1answer
125 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 ...
8
votes
2answers
3k 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 ...
8
votes
2answers
130 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?
3
votes
2answers
163 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 ...
1
vote
1answer
78 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 ...
2
votes
2answers
89 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 ...
1
vote
2answers
40 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 ...
1
vote
1answer
43 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 ...
2
votes
1answer
64 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 ...
2
votes
2answers
275 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 ...
3
votes
1answer
1k 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
3answers
98 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
62 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
2k 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
120 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
1k 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 ...