0
votes
1answer
51 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 ...
0
votes
2answers
32 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 ...
1
vote
1answer
157 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
80 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. ...
3
votes
2answers
397 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
218 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 ...
1
vote
2answers
125 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 ; ...
1
vote
1answer
705 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 ...
3
votes
2answers
343 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
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: ...
4
votes
2answers
5k 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 ...
4
votes
2answers
274 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 ...
0
votes
3answers
542 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 ...
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 ...
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
1answer
568 views

script to switch users keep running? [duplicate]

Possible Duplicate: Switching to superuser while shell script is running I need to switch users in a script and keep executing commands. I thought -c would help but i don't know how to use ...
2
votes
2answers
371 views

Am I using bash after this ordeal?

On Mountain Lion, host Coguaro, I login as user coconutpowder using bash: Coguaro:~ coconutpowder$ echo $0 -bash I need to run a command with elevated privileges so I try to su switch to root but ...
3
votes
1answer
160 views

On OS X, how do I log in interactively as root starting from my normal user account?

I have been doing this for a while: sudo su - but it uses 'sh' rather than 'bash', which is what I'd like to do. Which command will log me in as root and get me a bash shell even if that's not the ...
9
votes
4answers
3k views

su does not change user but does not respond with an error either

While logged in as root I would like to su to a specific regular user. I run su username and immediately receive the prompt back, still as root. There is no error given. I'm aware of the old "the user ...
1
vote
1answer
1k views

Run expect inside a bash script as another user

I am writing a bash script to install some small software I'm developing. That script is run with sudo (as root), but some of the commands that are executed by the script need (or should be) run with ...
0
votes
4answers
9k 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.
2
votes
2answers
872 views

su - username -c “./script.sh” -> no such file or directory

We have: a user nico. a folder /home/nico/script_home with some bash scripts: main.sh subscripta.sh sqlscripta.sh We connect as root and cd /home/nico/script_home/ Finally we run ./main.sh We ...
5
votes
2answers
1k views

Alternative to su/sudo on barebone system

I'd like to run some unit tests in a barebone chroot jail on Solaris. There's no su or sudo, and a copy of su (with libpam.so.1) just returns exit code 1 without any output, with or without ...
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 & " ...
7
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 ...
4
votes
2answers
14k views

su options - running command as another user

I was wondering how to run a command as another user from a script. I have the script's owner set as root. I also have the following command being run within the script to run the command as the ...