Questions tagged [su]

GENERAL SU SUPPORT IS OFF-TOPIC. Support questions may be asked on https://superuser.com. su is a utility to run a shell or other command as another user (root by default).

su is a Unix/Linux utility that runs a shell or a specified command as another user. By default, the other user is root, and su, with , is one of the two common ways of obtaining administrator privileges. Calling su usually requires typing the target user's password.

su originally stood for “super user” (it was only for running a root shell), and became later known as “substitute user” (or “switch user” or a number of similar backronyms) when it started accepting the target user name as an argument.

For system administration questions, see the su tag on Super User (for non-professionals), Server Fault (for professionals), or Unix & Linux.

460 questions
6
votes
3 answers

Run shell commands from android program

This question has been asked here before but the solutions provided are not working..I am trying to display the contents of /data/dalvik-cache folder. I know that to do this we need to become su. I even did that but still i am unable to execute a…
nikhil
  • 9,023
  • 22
  • 55
  • 81
6
votes
3 answers

How can I switch to the user jenkins in the middle of a ssh script?

I run ssh root@myhost "sh -x" < myremotecommands.sh where myremotecommands.sh contains: #!/bin/sh sudo su apt-get update sudo su -l -p jenkins whoami however the command whoami returns 'root'. I need to be user jenkins to perform some…
user77115
  • 5,517
  • 6
  • 37
  • 40
6
votes
5 answers

Getting a PID from a Background Process Run as Another User

Getting a background process ID is easy to do from the prompt by going: $ my_daemon & $ echo $! But what if I want to run it as a different user like: su - joe -c "/path/to/my_daemon &;" Now how can I capture the PID of my_daemon?
Dex
  • 12,527
  • 15
  • 69
  • 90
6
votes
6 answers

su and sudo in a shell script

There is a shell script (/bin/sh, not bash) that requires root permissions for execution. If it is ran by a normal user it should ask user a password to get root access and re-run itself. Now it uses the following code: if [ $(id -u) -ne 0 ]; then…
zserge
  • 2,212
  • 2
  • 31
  • 40
6
votes
2 answers

How to define environment variable in input command of su

This command has an empty output. su user -c "ABC=abc;echo $ABC" Any idea, how can I define a variable in the input command?
Attila Zobolyak
  • 739
  • 2
  • 10
  • 15
6
votes
4 answers

Android- performing su commands programatically does not work

I need my app to perform some su commands programatically (phone is rooted). When done using adb, the commands work. For instance: su -c "mkdir /sdcard/testdir" creates a directory called "testdir" in /sdcard. When I call: p =…
LoneDuck
  • 1,852
  • 1
  • 21
  • 28
6
votes
1 answer

Why fork bomb did not crash android?

This is the simplest fork bomb :() { :|: & }; : I executed it on many linux distros and all of them crashed. But when I executed this in an android terminal there was no effect even after granting Super user permissions. Any Explanations why it…
Shubham Batra
  • 1,278
  • 1
  • 14
  • 27
6
votes
3 answers

Execute shell commands and get output in a TextView

I want to execute some shell commands and get the output in a TextView. The command may have a continuous output like ping or logcat. Also, the TextView should scroll automatically as the command output is added in real-time. In order to do so, I…
Vinit Shandilya
  • 1,643
  • 5
  • 24
  • 44
6
votes
1 answer

How to net-ssh sudo su in Ruby

I'm trying to figure out how to a send chain of multiple net-ssh commands after a sudo su - #{su_user} in Ruby. My current code is below, and hangs with the sudo su command, even after the send_data "#{password}\n". Meanwhile, on the system, a…
SysTest RJR
  • 259
  • 4
  • 12
6
votes
1 answer

Escaping bash function arguments for use by su -c

I'd like to be able to write a function su_mt_user that (currently) looks like this: su_mt_user() { su someuser -c "$*" } The objective is to be able to use it like this: su_mt_user mt-auth --stuff etc Which would run the command mt-auth…
Etienne Perot
  • 4,764
  • 7
  • 40
  • 50
6
votes
2 answers

Getting output from busybox commands within Android app

For the life of me, I can't get my app to get the response from a process calling busybox from within su shell. I've tried three different methods, as well as tried a combination of the three to get it to work, but I can never get the output from…
z3nful
  • 81
  • 1
  • 8
5
votes
2 answers

Rooting ICS emulator; pushing su fails with "Out of memory"

I'm trying to root my ICS AVD, and have tried this: adb shell mount -o rw,remount -t yaffs2 /dev/block/mtdblock03 /system adb push su /system/xbin/su adb shell chmod 06755 /system adb shell chmod 06755 /system/xbin/su It fails with the…
Binoy Babu
  • 16,699
  • 17
  • 91
  • 134
5
votes
0 answers

Android: su doesn't affect groups

I am trying to access /proc/{PID} (or run ps) of another process in my app on android 7.1. I can not access any data on other PIDs because of this patch: https://android-review.googlesource.com/c/platform/system/core/+/181345 I thought that by…
Alonme
  • 1,364
  • 15
  • 28
5
votes
1 answer

Running commands in a script as another user using a here doc

I want to be able to switch users in the middle of a script. Here is one attempt: su - User << EOF /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
squarjn
  • 73
  • 1
  • 3
5
votes
4 answers

Executing scripts using more users

I'm writing a bash script which calls a lot of other scripts. Several scripts have to be executed as user_1 but several ones as user_2. The scripts should be called in strict sequence. I start my script as user_1 and use su many times to become…
Attila Zobolyak
  • 739
  • 2
  • 10
  • 15
1 2
3
30 31