Tagged Questions

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

learn more… | top users | synonyms

1
vote
1answer
25 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
25 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
109 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 ...
2
votes
3answers
570 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
52 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
56 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
2answers
67 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
2answers
39 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 ...
2
votes
2answers
66 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
32 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
vote
1answer
166 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
91 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
1answer
553 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 ...
3
votes
1answer
44 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
46 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
40 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 ...
3
votes
2answers
423 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 ...
2
votes
1answer
261 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 ...
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 ...
2
votes
1answer
56 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. ...
2
votes
1answer
141 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 ...
0
votes
2answers
121 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 ...
1
vote
2answers
71 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
77 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. ...
2
votes
3answers
158 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 ...
1
vote
2answers
138 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
134 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
828 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 ...
2
votes
1answer
154 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
339 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
3answers
153 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? ...
1
vote
1answer
90 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?
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
346 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 ...
3
votes
2answers
372 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 ...
2
votes
2answers
101 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 ...
8
votes
2answers
176 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?
1
vote
2answers
58 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 ...
2
votes
1answer
92 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 ...
1
vote
1answer
72 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 ...
0
votes
3answers
236 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 - ...
11
votes
2answers
8k 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 ...
1
vote
1answer
78 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
5k 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: ...
0
votes
0answers
126 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
5k 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 ...
5
votes
2answers
6k 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
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 ...