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

learn more… | top users | synonyms

1
vote
2answers
34 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 ...
0
votes
0answers
27 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 ...
6
votes
5answers
5k views

How do I suppress dd output?

I have a bash script that creates some file using dd. The problem is dd throws a great amount of output that is going to mess with the output of my script. Searching around I've found a solution: dd ...
2
votes
2answers
43 views

how to write a script that will run commands after su, without using -c

I'm trying to automate a standard activity on a system I do not have root access on. The administrator of the systems have given me authority to run sudo su - 'user' command, and only that command. ...
1
vote
1answer
21 views

Why can't I login in as the ftp user?

After installing vsftpd I have the user ftp on my system. I assigned a password to this account. However, I still cannot login as the ftp user (on the command line, without any ftp-protocol involved). ...
-1
votes
0answers
28 views

FreeBSD switch to user with nologin

I am running FreeBSD jails. i have a user i need to login as to run some commands. The user shell account is nologin. Without switching the users shell. or running su commands for each command i need ...
26
votes
6answers
16k 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 ...
1
vote
1answer
104 views

Permission denied when trying to run script as other user

I'm trying to run a script as another user that starts a piece of software (Etherpad), which is run like so (from root): su -c "/var/www/etherpad-lite/bin/run.sh" -s /bin/bash etherpad but I'm ...
5
votes
1answer
52 views

Getting the process-id out of command launched with “su -c”

I am running a java program inside a shell and writing the process-id to a text file. So when I do this: nohup java app.Main > /dev/null 2>&1 & echo $! > /var/run/app.pid It works. ...
5
votes
3answers
1k 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 ...
5
votes
1answer
463 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 ...
0
votes
4answers
8k 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
37 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
34 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
28 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
105 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
348 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
40 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
6k 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
53 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
625 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
92 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
86 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
51 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
61 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
30 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
485 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
1k 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
152 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
706 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
105 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
114 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
269 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 ...
76
votes
6answers
23k 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
123 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
135 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
3k 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
121 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
951 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
62 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
1k 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
216 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
6k 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
150 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
243 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
83 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
99 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
49 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
61 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 ...